Skip to content

Commit 795bee7

Browse files
committed
update
1 parent 477b8b1 commit 795bee7

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ data/api.json
161161
data/bind_domain.pl
162162
data/unauthorized_status.pl
163163
data/auth_secret.pl
164+
data/panelSpeed.pl
164165

165166
plugins/vip_*
166167
plugins/own_*
@@ -185,4 +186,5 @@ plugins/goedge-node
185186
plugins/goedge-happy
186187
plugins/dztasks
187188

188-
data/default_new.pl
189+
190+

data/default_new.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
88rr2g7e

web/admin/files/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ def recycle_bin():
156156
return file.toggleRecycleBin()
157157

158158

159+
# 回收站文件
160+
@blueprint.route('/close_recycle_bin', endpoint='close_recycle_bin', methods=['POST'])
161+
@panel_login_required
162+
def close_recycle_bin():
163+
return file.closeRecycleBin()
164+
165+
159166

160167

161168

web/core/mw.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,31 @@ def writeDbLog(stype, msg, args=(), uid=1):
610610
print("writeDbLog:"+str(e))
611611
return False
612612

613+
def writeSpeed(title, used, total, speed=0):
614+
path = getPanelDir()
615+
speed_file= path + '/data/panelSpeed.pl'
616+
# 写进度
617+
if not title:
618+
data = {'title': None, 'progress': 0,'total': 0, 'used': 0, 'speed': 0}
619+
else:
620+
progress = int((100.0 * used / total))
621+
data = {'title': title, 'progress': progress,'total': total, 'used': used, 'speed': speed}
622+
writeFile(speed_file, json.dumps(data))
623+
return True
624+
625+
626+
def getSpeed():
627+
path = getPanelDir()
628+
speed_file= path + '/data/panelSpeed.pl'
629+
# 取进度
630+
path = getPanelDir()
631+
data = readFile(speed_file)
632+
if not data:
633+
data = json.dumps({'title': None, 'progress': 0,'total': 0, 'used': 0, 'speed': 0})
634+
writeFile(speed_file, data)
635+
return json.loads(data)
636+
637+
613638

614639
def M(table=''):
615640
import core.db as db

web/utils/file.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from admin import model
1616

1717
import core.mw as mw
18+
import thisdb
1819

1920
def getFileBody(path):
2021
if not os.path.exists(path):
@@ -284,7 +285,7 @@ def fileDelete(path):
284285
mw.execShell(cmd)
285286

286287
try:
287-
recycle_bin = model.getOption('recycle_bin')
288+
recycle_bin = thisdb.getOption('recycle_bin')
288289
if recycle_bin == 'open':
289290
if mvRecycleBin(path):
290291
return mw.returnData(True, '已将文件移动到回收站!')
@@ -303,7 +304,7 @@ def dirDelete(path):
303304
if path.find('.user.ini'):
304305
os.system("which chattr && chattr -i '" + path + "'")
305306
try:
306-
recycle_bin = model.getOption('recycle_bin')
307+
recycle_bin = thisdb.getOption('recycle_bin')
307308
if recycle_bin == 'open':
308309
if mvRecycleBin(path):
309310
return mw.returnData(True, '已将文件移动到回收站!')
@@ -315,19 +316,19 @@ def dirDelete(path):
315316

316317
# 关闭
317318
def toggleRecycleBin():
318-
recycle_bin = model.getOption('recycle_bin')
319+
recycle_bin = thisdb.getOption('recycle_bin')
319320
if recycle_bin == 'open':
320-
model.setOption('recycle_bin','close')
321+
thisdb.setOption('recycle_bin','close')
321322
mw.writeLog('文件管理', '已关闭回收站功能!')
322323
return mw.returnData(True, '已关闭回收站功能!')
323324
else:
324-
model.setOption('recycle_bin','open')
325+
thisdb.setOption('recycle_bin','open')
325326
mw.writeLog('文件管理', '已开启回收站功能!')
326327
return mw.returnData(True, '已开启回收站功能!')
327328

328329
def getRecycleBin():
329330
rb_dir = mw.getRecycleBinDir()
330-
recycle_bin = model.getOption('recycle_bin')
331+
recycle_bin = thisdb.getOption('recycle_bin')
331332

332333
data = {}
333334
data['dirs'] = []
@@ -392,6 +393,26 @@ def reRecycleBin(path):
392393
mw.writeLog('文件管理', msg)
393394
return mw.returnData(False, '恢复失败!')
394395

396+
397+
def closeRecycleBin():
398+
rb_dir = mw.getRecycleBinDir()
399+
mw.execShell('which chattr && chattr -R -i ' + rb_dir)
400+
rlist = os.listdir(rb_dir)
401+
i = 0
402+
l = len(rlist)
403+
for name in rlist:
404+
i += 1
405+
path = rb_dir + '/' + name
406+
mw.writeSpeed(name, i, l)
407+
if os.path.isdir(path):
408+
shutil.rmtree(path)
409+
else:
410+
os.remove(path)
411+
mw.writeSpeed(None, 0, 0)
412+
mw.writeLog('文件管理', '已清空回收站!')
413+
return mw.returnJson(True, '已清空回收站!')
414+
415+
395416
# 设置文件和目录权限
396417
def setMode(path):
397418
s_path = os.path.dirname(path)

0 commit comments

Comments
 (0)