Update filemanager.py to fix filesize issues
Fix filesize issues https://github.com/usmannasir/cyberpanel/issues/146
This commit is contained in:
parent
589f87aeb0
commit
5bbebe418b
|
|
@ -173,6 +173,15 @@ class FileManager:
|
|||
except:
|
||||
print("Permisson not changed")
|
||||
|
||||
|
||||
def bytes_to_human_readable(num, suffix='B'):
|
||||
for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
|
||||
if abs(num) < 1024.0:
|
||||
return "%3.1f%s%s" % (num, unit, suffix)
|
||||
num /= 1024.0
|
||||
return "%.1f%s%s" % (num, 'Yi', suffix)
|
||||
|
||||
|
||||
def listForTable(self):
|
||||
try:
|
||||
finalData = {}
|
||||
|
|
@ -221,7 +230,7 @@ class FileManager:
|
|||
if currentFile[0][0] == 'd':
|
||||
dirCheck = 1
|
||||
|
||||
size = str(int(int(currentFile[4]) / float(1024)))
|
||||
size = bytes_to_human_readable(int(currentFile[4]))
|
||||
lastModified = currentFile[5] + ' ' + currentFile[6] + ' ' + currentFile[7]
|
||||
finalData[str(counter)] = [currentFile[-1], currentFile[-1], lastModified, size, currentFile[0],
|
||||
dirCheck]
|
||||
|
|
|
|||
Loading…
Reference in New Issue