From a488f106ca14cbd392a145680a630d8c6ee23b7f Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Sep 2023 00:37:23 +0800 Subject: [PATCH] Update files_api.py --- class/core/files_api.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/class/core/files_api.py b/class/core/files_api.py index a4460d276..f7e7598cb 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -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 &"