diff --git a/class/core/files_api.py b/class/core/files_api.py index 86149b401..7dfbb12e2 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -8,6 +8,7 @@ import public import re import json import pwd +import shutil from flask import request from flask import send_file, send_from_directory @@ -220,6 +221,30 @@ class files_api: public.writeLog('文件管理', msg) return public.returnJson(True, msg) + # 获取进度 + def getSpeedApi(self): + data = public.getSpeed() + print data + return public.returnJson(True, '已清空回收站!', data) + + def closeRecycleBinApi(self): + rPath = self.rPath + os.system('which chattr && chattr -R -i ' + rPath) + rlist = os.listdir(rPath) + i = 0 + l = len(rlist) + for name in rlist: + i += 1 + path = rPath + name + public.writeSpeed(name, i, l) + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.remove(path) + public.writeSpeed(None, 0, 0) + public.writeLog('文件管理', '已清空回收站!') + return public.returnJson(True, '已清空回收站!') + def deleteDirApi(self): path = request.form.get('path', '').encode('utf-8') if not os.path.exists(path): diff --git a/route/__init__.py b/route/__init__.py index fac54c106..4261b162b 100755 --- a/route/__init__.py +++ b/route/__init__.py @@ -84,11 +84,14 @@ def isLogined(): def publicObject(toObject, func, action=None, get=None): name = funConvert(func) + 'Api' - if hasattr(toObject, name): - efunc = 'toObject.' + name + '()' - data = eval(efunc) - return data - return public.retFail('访问异常!') + try: + if hasattr(toObject, name): + efunc = 'toObject.' + name + '()' + data = eval(efunc) + return data + except Exception as e: + data = {'msg': '访问异常:' + str(e) + '!', "status": False} + return public.getInfo(data) @app.route("/test") diff --git a/route/static/app/files.js b/route/static/app/files.js index f83a41c3a..6d9880a0a 100755 --- a/route/static/app/files.js +++ b/route/static/app/files.js @@ -262,7 +262,7 @@ function closeRecycleBin(){ setTimeout(function(){ getSpeed('.myspeed'); },1000); - $.post('/files?action=Close_Recycle_bin','',function(rdata){ + $.post('/files/close_recycle_bin', '', function(rdata){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:5}); $("#RecycleBody").html(''); @@ -286,18 +286,15 @@ function setRecycleBin(db){ //取数据 function getFiles(Path) { - console.log(Path); var searchtype = Path; if(isNaN(Path)){ - var p = '1'; + var p = 1; Path = encodeURIComponent(Path); - console.log(1,Path); } else { - var p = '1'; + var p = Path; Path = getCookie('open_dir_path'); - console.log(2,Path); + Path = encodeURIComponent(Path); } - console.log(Path); var search = ''; var searchV = $("#SearchValue").val(); @@ -461,7 +458,7 @@ function getFiles(Path) { if (rdata.PATH != '/') { BarTools += ' '; } - setCookie('Path',rdata.PATH); + setCookie('open_dir_path',rdata.PATH); BarTools += ' '; var copyName = getCookie('copyFileName'); var cutName = getCookie('cutFileName'); @@ -548,8 +545,10 @@ function getFiles(Path) { }); PathPlaceBtn(rdata.PATH); },'json'); - //setTimeout(function(){getCookie('path');},200); + setTimeout(function(){getCookie('open_dir_path');},200); } + + //统计选择数量 function totalFile(){ var el = $("input[name='id']"); diff --git a/route/static/app/public.js b/route/static/app/public.js index 38efe960d..79cb95f5e 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -926,14 +926,18 @@ function bindPaneldel(id){ } function getSpeed(sele){ - if(!$(sele)) return; - $.get('/ajax?action=GetSpeed',function(speed){ - if(speed.title === null) return; - mspeed = ''; + if(!$(sele)) { + return; + } + $.get('/files/get_speed',function(speed){ + if(speed.title === null){ + return; + } + var mspeed = ''; if(speed.speed > 0){ - mspeed = ''+ToSize(speed.speed)+'/s'; + mspeed = ''+toSize(speed.speed)+'/s'; } - body = '

'+speed.title+'

\ + var body = '

'+speed.title+'

\
'+speed.progress+'%
\

'+speed.used+'/'+speed.total+''+mspeed+'

'; $(sele).prev().hide(); @@ -944,7 +948,7 @@ function getSpeed(sele){ setTimeout(function(){ getSpeed(sele); },1000); - }); + },'json'); } //消息盒子 function messageBox() {