Optional stats to dirList websocket API command
This commit is contained in:
parent
8a71bf65cd
commit
0bc9374a7d
1 changed files with 13 additions and 2 deletions
|
@ -6,6 +6,7 @@ import shutil
|
|||
import re
|
||||
import copy
|
||||
import logging
|
||||
import stat
|
||||
|
||||
import gevent
|
||||
|
||||
|
@ -655,8 +656,18 @@ class UiWebsocket(object):
|
|||
|
||||
# List directories in a directory
|
||||
@flag.async_run
|
||||
def actionDirList(self, to, inner_path):
|
||||
def actionDirList(self, to, inner_path, stats=False):
|
||||
try:
|
||||
if stats:
|
||||
back = []
|
||||
for file_name in self.site.storage.list(inner_path):
|
||||
file_stats = os.stat(self.site.storage.getPath(inner_path + "/" + file_name))
|
||||
is_dir = stat.S_ISDIR(file_stats.st_mode)
|
||||
back.append(
|
||||
{"name": file_name, "size": file_stats.st_size, "is_dir": is_dir}
|
||||
)
|
||||
return back
|
||||
else:
|
||||
return list(self.site.storage.list(inner_path))
|
||||
except Exception as err:
|
||||
self.log.error("dirList %s error: %s" % (inner_path, Debug.formatException(err)))
|
||||
|
|
Loading…
Reference in a new issue