mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 05:59:17 +02:00
Fix #1105: Can now launch server import from the UI
This commit is contained in:
parent
0a93aec8c9
commit
788c12748f
17 changed files with 476 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
import pathlib
|
||||
import mimetypes
|
||||
|
||||
import magic
|
||||
|
@ -130,3 +132,21 @@ def increment_downloads_count(upload, user, wsgi_request):
|
|||
duration = max(upload.duration or 0, settings.MIN_DELAY_BETWEEN_DOWNLOADS_COUNT)
|
||||
|
||||
cache.set(cache_key, 1, duration)
|
||||
|
||||
|
||||
def browse_dir(root, path):
|
||||
if ".." in path:
|
||||
raise ValueError("Relative browsing is not allowed")
|
||||
|
||||
root = pathlib.Path(root)
|
||||
real_path = root / path
|
||||
|
||||
dirs = []
|
||||
files = []
|
||||
for el in sorted(os.listdir(real_path)):
|
||||
if os.path.isdir(real_path / el):
|
||||
dirs.append({"name": el, "dir": True})
|
||||
else:
|
||||
files.append({"name": el, "dir": False})
|
||||
|
||||
return dirs + files
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue