Update files_api.py

pull/109/head
midoks 4 years ago
parent b0dc798129
commit 6a9246619d
  1. 29
      class/core/files_api.py

@ -121,6 +121,7 @@ class files_api:
def getDirSizeApi(self): def getDirSizeApi(self):
path = request.form.get('path', '').encode('utf-8') path = request.form.get('path', '').encode('utf-8')
tmp = self.getDirSize(path) tmp = self.getDirSize(path)
print(tmp)
return mw.returnJson(True, tmp[0].split()[0]) return mw.returnJson(True, tmp[0].split()[0])
def getDirApi(self): def getDirApi(self):
@ -796,8 +797,6 @@ done
pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8') pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8')
data['PAGE'] = pageObj[0] data['PAGE'] = pageObj[0]
print('....eeee.11..')
i = 0 i = 0
n = 0 n = 0
for filename in os.listdir(path): for filename in os.listdir(path):
@ -810,14 +809,17 @@ done
if i < pageObj[1].SHIFT: if i < pageObj[1].SHIFT:
continue continue
# print(path, filename)
try: try:
filePath = (path + '/' + filename).encode('utf8') filePath = str(path, encoding='utf-8') + '/' + \
str(filename, encoding='utf-8')
link = '' link = ''
if os.path.islink(filePath): if os.path.islink(filePath):
filePath = os.readlink(filePath) filePath = os.readlink(filePath)
link = ' -> ' + filePath link = ' -> ' + str(filePath, encoding='utf-8')
if not os.path.exists(filePath): if not os.path.exists(filePath):
filePath = path + '/' + filePath filePath = str(path, encoding='utf-8') + \
'/' + str(filePath, encoding='utf-8')
if not os.path.exists(filePath): if not os.path.exists(filePath):
continue continue
@ -827,21 +829,22 @@ done
user = '' user = ''
try: try:
user = pwd.getpwuid(stat.st_uid).pw_name user = pwd.getpwuid(stat.st_uid).pw_name
except: except Exception as ee:
user = str(stat.st_uid) user = str(stat.st_uid)
size = str(stat.st_size) size = str(stat.st_size)
if os.path.isdir(filePath): if os.path.isdir(filePath):
dirnames.append(filename + ';' + size + ';' + dirnames.append(str(filename, encoding='utf-8') + ';' + str(size, encoding='utf-8') + ';' +
mtime + ';' + accept + ';' + user + ';' + link) str(mtime, encoding='utf-8') + ';' + accept + ';' + user + ';' + link)
else: else:
filenames.append(filename + ';' + size + ';' + filenames.append(str(filename, encoding='utf-8') + ';' + str(size, encoding='utf-8') + ';' +
mtime + ';' + accept + ';' + user + ';' + link) str(mtime, encoding='utf-8') + ';' + accept + ';' + user + ';' + link)
n += 1 n += 1
except Exception as e: except Exception as e:
print(e) print('getdir:dd.', e)
continue continue
data['DIR'] = sorted(dirnames) data['DIR'] = sorted(dirnames)
data['FILES'] = sorted(filenames) data['FILES'] = sorted(filenames)
data['PATH'] = path.replace('//', '/') data['PATH'] = str(path, encoding='utf-8').replace('//', '/')
return mw.getJson(data) return mw.getJson(data)

Loading…
Cancel
Save