support for autoremoving X days old files

This commit is contained in:
2018-11-17 23:24:32 +02:00
parent 70420bd035
commit 375628255d
5 changed files with 164 additions and 6 deletions

View File

@@ -304,6 +304,8 @@ def file_list(name, token):
return share
files = []
for file in iter_folder_files(share['path'], version_folder = app.config['VERSION_FOLDER']):
if file_autoremove(file, share, notify):
continue
files.append(path2url(file))
files.append("")
return "\n".join(files), 200
@@ -379,6 +381,8 @@ def file_ls(name, token):
files = []
maxlen = 4
for file in iter_folder_files(share['path'], version_folder = app.config['VERSION_FOLDER']):
if file_autoremove(file, share, notify):
continue
files.append(file)
maxlen = max(maxlen, len(file))
details = []
@@ -437,6 +441,8 @@ def list_view(name, token = None):
files = []
for file in iter_folder_files(share['path'], version_folder = app.config['VERSION_FOLDER']):
if file_autoremove(file, share, notify):
continue
status = file_stat(share['path'],file)
status.update({
'token': get_direct_token(share, file),
@@ -500,6 +506,7 @@ def download_direct(name,token,filename):
"operation": "unauthorized_direct_download"
})
return 'Incorrect token', 403
file_autoremove(filename, share, notify)
file_path = os.path.join(share['path'], filename)
if not os.path.exists(file_path):
return 'No such file', 404
@@ -767,6 +774,7 @@ def download_file(name, filename, token = None):
return share
if not is_path_safe(filename):
return "Incorrect path", 403
file_autoremove(filename, share, notify)
file_path = os.path.join(share['path'], filename)
if not os.path.exists(file_path):
return 'No such file, '+file_path, 404
@@ -896,6 +904,8 @@ def zip_share(share):
)
zf = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
for file in iter_folder_files(share['path'], version_folder = app.config['VERSION_FOLDER']):
if file_autoremove(file, share, notify):
continue
fp = os.path.join(share['path'], file)
if os.path.isdir(fp):
continue