curls follow redirects. file listings have days to removal

This commit is contained in:
2019-08-30 15:57:00 +03:00
parent 1fa2fcfe06
commit 0f16ecbcd9
5 changed files with 42 additions and 23 deletions

View File

@@ -154,9 +154,18 @@ def file_mime(filename):
# magic not imported
return "NA"
def file_stat(path, filename):
full_path = os.path.join(path, filename)
def file_stat(share, filename):
full_path = os.path.join(share['path'], filename)
s = os.stat(full_path)
autoremove = get_or_none('autoremove', share, 0)
if autoremove == 0:
to_remove = "NA"
else:
now = datetime.now()
then = datetime.fromtimestamp(s.st_mtime)
diff = now - then
to_remove = "%d d"%( autoremove - diff.days, )
return {
'size': file_size_MB(s.st_size),
'hsize': file_size_human(s.st_size, HTML = False),
@@ -164,7 +173,8 @@ def file_stat(path, filename):
'name': filename,
'url': path2url(filename),
'editable': (s.st_size < 65536 and filename.endswith(".txt")),
'mime': file_mime(full_path)
'mime': file_mime(full_path),
'to_remove': to_remove
}