Update files_api.py

This commit is contained in:
midoks
2023-09-15 00:37:23 +08:00
parent f05de84dc2
commit a488f106ca
+11 -2
View File
@@ -844,7 +844,13 @@ class files_api:
extension = os.path.splitext(filename)[-1]
extension = extension.strip('.')
if not extension in ['gz', 'zip', 'rar']:
tar_gz = 'tar.gz'
tar_gz_len = len(tar_gz)
suffix_gz = sfile[-tar_gz_len:]
if suffix_gz == tar_gz:
extension = suffix_gz
if not extension in ['tar.gz', 'gz', 'zip', 'rar']:
return mw.returnJson(False, '现在仅支持gz,zip,rar格式解压!')
if mw.isAppleSystem() and extension == 'rar':
@@ -856,10 +862,13 @@ class files_api:
cmd = "cd " + path + " && unzip -o -d '" + dfile + \
"' '" + sfile + "' > " + tmps + " 2>&1 &"
mw.execShell(cmd)
if extension == 'gz':
if extension == 'tar.gz':
cmd = "cd " + path + " && tar -zxvf " + sfile + \
" -C " + dfile + " > " + tmps + " 2>&1 &"
mw.execShell(cmd)
if extension == 'gz':
cmd = "cd " + path + " && gunzip -k " + sfile + " > " + tmps + " 2>&1 &"
mw.execShell(cmd)
if extension == 'rar':
cmd = "cd " + path + " && unrar x " + sfile + \
" " + dfile + " > " + tmps + " 2>&1 &"