1515from admin import model
1616
1717import core .mw as mw
18+ import thisdb
1819
1920def 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# 关闭
317318def 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
328329def 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# 设置文件和目录权限
396417def setMode (path ):
397418 s_path = os .path .dirname (path )
0 commit comments