diff --git a/README.md b/README.md index cfcc0de40..b6fdf5cd6 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443: * 初始花安装提示。 * 面板设置UI优化。 * 加入BasicAuth认证功能。 -* MYSQL[APT,YUM]安装检查优化。 +* MySQL[APT,YUM]安装检查优化。 +* MySQL导入优化,对sql后缀支持。 ### JSDelivr安装地址 diff --git a/plugins/mysql-apt/index.py b/plugins/mysql-apt/index.py index a61d2679a..31147380b 100755 --- a/plugins/mysql-apt/index.py +++ b/plugins/mysql-apt/index.py @@ -691,8 +691,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, '导入数据库格式不对!') @@ -721,6 +720,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 + file + if import_sql == "": return mw.returnJson(False, '未找SQL文件') @@ -733,7 +735,8 @@ def importDbExternal(): # print(mysql_cmd) os.system(mysql_cmd) - os.remove(import_sql) + if ext != 'sql': + os.remove(import_sql) return mw.returnJson(True, 'ok') diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index c8f4f7f0d..575d5876c 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -670,8 +670,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, '导入数据库格式不对!') @@ -700,6 +699,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 + file + if import_sql == "": return mw.returnJson(False, '未找SQL文件') @@ -712,7 +714,8 @@ def importDbExternal(): # print(mysql_cmd) os.system(mysql_cmd) - os.remove(import_sql) + if ext != 'sql': + os.remove(import_sql) return mw.returnJson(True, 'ok')