右键解压方法缺失

pull/662/head
Mr Chen 5 months ago
parent dd685b664d
commit 48468a1c2d
  1. 12
      web/admin/files/files.py
  2. 23
      web/utils/file.py

@ -163,7 +163,17 @@ def get_dir():
dir_list['page'] = mw.getPage({'p':page, 'row': row, 'tojs':'getFiles', 'count': dir_list['count']}, '1,2,3,4,5,6,7,8')
return dir_list
# 解压
# 解压ZIP
@blueprint.route('/unzip', endpoint='unzip', methods=['POST'])
@panel_login_required
def unzip():
sfile = request.form.get('sfile', '')
dfile = request.form.get('dfile', '')
stype = request.form.get('type', '')
path = request.form.get('path', '')
return file.unzip(sfile, dfile, stype, path)
# 解压可解压文件
@blueprint.route('/uncompress', endpoint='uncompress', methods=['POST'])
@panel_login_required
def uncompress():

@ -103,6 +103,29 @@ def mvFile(sfile, dfile):
except Exception as e:
return mw.returnData(False, '移动或重名命文件失败!'+str(e))
def unzip(sfile, dfile, stype, path):
if not os.path.exists(sfile):
return mw.returnData(False, '指定文件不存在!')
try:
tmps = mw.getPanelDir() + '/logs/panel_exec.log'
if stype == 'zip':
mw.execShell("cd " + path + " && unzip -o -d '" + dfile +"' '" + sfile + "' > " + tmps + " 2>&1 &")
else:
sfiles = ''
for sfile in sfile.split(','):
if not sfile:
continue
sfiles += " '" + sfile + "'"
mw.execShell("cd " + path + " && tar -zxvf " + sfiles +" -C " + dfile + " > " + tmps + " 2>&1 &")
if os.path.exists(dfile):
setFileAccept(dfile)
mw.writeLog("文件管理", '文件[{1}]解压[{2}]成功!', (sfile, dfile))
return mw.returnData(True, '文件解压成功!')
except:
return mw.returnData(False, '文件解压失败!')
def uncompress(sfile, dfile, path):
if not os.path.exists(sfile):
return mw.returnData(False, '指定文件不存在!')

Loading…
Cancel
Save