pull/632/head
Mr Chen 6 months ago
parent 477b8b1f73
commit 795bee7de3
  1. 4
      .gitignore
  2. 1
      data/default_new.pl
  3. 7
      web/admin/files/__init__.py
  4. 25
      web/core/mw.py
  5. 33
      web/utils/file.py

4
.gitignore vendored

@ -161,6 +161,7 @@ data/api.json
data/bind_domain.pl data/bind_domain.pl
data/unauthorized_status.pl data/unauthorized_status.pl
data/auth_secret.pl data/auth_secret.pl
data/panelSpeed.pl
plugins/vip_* plugins/vip_*
plugins/own_* plugins/own_*
@ -185,4 +186,5 @@ plugins/goedge-node
plugins/goedge-happy plugins/goedge-happy
plugins/dztasks plugins/dztasks
data/default_new.pl

@ -156,6 +156,13 @@ def recycle_bin():
return file.toggleRecycleBin() return file.toggleRecycleBin()
# 回收站文件
@blueprint.route('/close_recycle_bin', endpoint='close_recycle_bin', methods=['POST'])
@panel_login_required
def close_recycle_bin():
return file.closeRecycleBin()

@ -610,6 +610,31 @@ def writeDbLog(stype, msg, args=(), uid=1):
print("writeDbLog:"+str(e)) print("writeDbLog:"+str(e))
return False return False
def writeSpeed(title, used, total, speed=0):
path = getPanelDir()
speed_file= path + '/data/panelSpeed.pl'
# 写进度
if not title:
data = {'title': None, 'progress': 0,'total': 0, 'used': 0, 'speed': 0}
else:
progress = int((100.0 * used / total))
data = {'title': title, 'progress': progress,'total': total, 'used': used, 'speed': speed}
writeFile(speed_file, json.dumps(data))
return True
def getSpeed():
path = getPanelDir()
speed_file= path + '/data/panelSpeed.pl'
# 取进度
path = getPanelDir()
data = readFile(speed_file)
if not data:
data = json.dumps({'title': None, 'progress': 0,'total': 0, 'used': 0, 'speed': 0})
writeFile(speed_file, data)
return json.loads(data)
def M(table=''): def M(table=''):
import core.db as db import core.db as db

@ -15,6 +15,7 @@ import time
from admin import model from admin import model
import core.mw as mw import core.mw as mw
import thisdb
def getFileBody(path): def getFileBody(path):
if not os.path.exists(path): if not os.path.exists(path):
@ -284,7 +285,7 @@ def fileDelete(path):
mw.execShell(cmd) mw.execShell(cmd)
try: try:
recycle_bin = model.getOption('recycle_bin') recycle_bin = thisdb.getOption('recycle_bin')
if recycle_bin == 'open': if recycle_bin == 'open':
if mvRecycleBin(path): if mvRecycleBin(path):
return mw.returnData(True, '已将文件移动到回收站!') return mw.returnData(True, '已将文件移动到回收站!')
@ -303,7 +304,7 @@ def dirDelete(path):
if path.find('.user.ini'): if path.find('.user.ini'):
os.system("which chattr && chattr -i '" + path + "'") os.system("which chattr && chattr -i '" + path + "'")
try: try:
recycle_bin = model.getOption('recycle_bin') recycle_bin = thisdb.getOption('recycle_bin')
if recycle_bin == 'open': if recycle_bin == 'open':
if mvRecycleBin(path): if mvRecycleBin(path):
return mw.returnData(True, '已将文件移动到回收站!') return mw.returnData(True, '已将文件移动到回收站!')
@ -315,19 +316,19 @@ def dirDelete(path):
# 关闭 # 关闭
def toggleRecycleBin(): def toggleRecycleBin():
recycle_bin = model.getOption('recycle_bin') recycle_bin = thisdb.getOption('recycle_bin')
if recycle_bin == 'open': if recycle_bin == 'open':
model.setOption('recycle_bin','close') thisdb.setOption('recycle_bin','close')
mw.writeLog('文件管理', '已关闭回收站功能!') mw.writeLog('文件管理', '已关闭回收站功能!')
return mw.returnData(True, '已关闭回收站功能!') return mw.returnData(True, '已关闭回收站功能!')
else: else:
model.setOption('recycle_bin','open') thisdb.setOption('recycle_bin','open')
mw.writeLog('文件管理', '已开启回收站功能!') mw.writeLog('文件管理', '已开启回收站功能!')
return mw.returnData(True, '已开启回收站功能!') return mw.returnData(True, '已开启回收站功能!')
def getRecycleBin(): def getRecycleBin():
rb_dir = mw.getRecycleBinDir() rb_dir = mw.getRecycleBinDir()
recycle_bin = model.getOption('recycle_bin') recycle_bin = thisdb.getOption('recycle_bin')
data = {} data = {}
data['dirs'] = [] data['dirs'] = []
@ -392,6 +393,26 @@ def reRecycleBin(path):
mw.writeLog('文件管理', msg) mw.writeLog('文件管理', msg)
return mw.returnData(False, '恢复失败!') return mw.returnData(False, '恢复失败!')
def closeRecycleBin():
rb_dir = mw.getRecycleBinDir()
mw.execShell('which chattr && chattr -R -i ' + rb_dir)
rlist = os.listdir(rb_dir)
i = 0
l = len(rlist)
for name in rlist:
i += 1
path = rb_dir + '/' + name
mw.writeSpeed(name, i, l)
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
mw.writeSpeed(None, 0, 0)
mw.writeLog('文件管理', '已清空回收站!')
return mw.returnJson(True, '已清空回收站!')
# 设置文件和目录权限 # 设置文件和目录权限
def setMode(path): def setMode(path):
s_path = os.path.dirname(path) s_path = os.path.dirname(path)

Loading…
Cancel
Save