diff --git a/class/core/mw.py b/class/core/mw.py index d8f7fecf6..029192ff2 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -167,6 +167,12 @@ def getOsID(): return data[0].strip() +def getFileSuffix(file): + tmp = file.split('.') + ext = tmp[len(tmp) - 1] + return ext + + def isAppleSystem(): if getOs() == 'darwin': return True diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 504c483fc..a4cc546d3 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -857,8 +857,7 @@ def importDbExternal(): return mw.returnJson(False, '文件突然消失?') exts = ['sql', 'gz', 'zip'] - tmp = file.split('.') - ext = tmp[len(tmp) - 1] + ext = mw.getFileSuffix(file) if ext not in exts: return mw.returnJson(False, '导入数据库格式不对!') @@ -887,6 +886,9 @@ def importDbExternal(): mw.execShell(cmd) import_sql = import_dir + tmpFile + if file.find(".sql") > -1 and file.find(".sql.gz") == -1: + import_sql = import_dir + tmpFile + if import_sql == "": return mw.returnJson(False, '未找SQL文件')