Update file.py

pull/694/head
Mr Chen 4 months ago
parent 0dc2b635ae
commit 255ed5944f
  1. 15
      web/utils/file.py

@ -496,10 +496,17 @@ def saveBody(path, data, encoding):
def sortFileList(path, ftype = 'mtime', sort = 'desc'):
flist = os.listdir(path)
if ftype == 'mtime':
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=False)
try:
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=False)
except Exception as e:
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getctime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getctime(os.path.join(path,f)), reverse=False)
if ftype == 'size':
if sort == 'desc':

Loading…
Cancel
Save