diff --git a/class/core/files_api.py b/class/core/files_api.py index b3eb5105f..45a16a24f 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -130,6 +130,76 @@ class files_api: public.writeFile(isTask, 'True') self.setFileAccept(path + '/' + filename) return public.returnJson(True, '已将下载任务添加到队列!') + + def getRecycleBinApi(self): + rPath = public.getRootDir() + '/Recycle_bin/' + if not os.path.exists(rPath): + os.system('mkdir -p ' + rPath) + data = {} + data['dirs'] = [] + data['files'] = [] + data['status'] = os.path.exists('data/recycle_bin.pl') + data['status_db'] = os.path.exists('data/recycle_bin_db.pl') + for file in os.listdir(rPath): + try: + tmp = {} + fname = rPath + file + tmp1 = file.split('_bt_') + tmp2 = tmp1[len(tmp1) - 1].split('_t_') + tmp['rname'] = file + tmp['dname'] = file.replace('_mw_', '/').split('_t_')[0] + tmp['name'] = tmp2[0] + tmp['time'] = int(float(tmp2[1])) + if os.path.islink(fname): + filePath = os.readlink(fname) + link = ' -> ' + filePath + if os.path.exists(filePath): + tmp['size'] = os.path.getsize(filePath) + else: + tmp['size'] = 0 + else: + tmp['size'] = os.path.getsize(fname) + if os.path.isdir(fname): + data['dirs'].append(tmp) + else: + data['files'].append(tmp) + except: + continue + return public.returnJson(True, 'OK', data) + + # 回收站开关 + def recycleBinApi(self): + c = 'data/recycle_bin.pl' + db = request.form.get('db', '').encode('utf-8') + if db != '': + c = 'data/recycle_bin_db.pl' + if os.path.exists(c): + os.remove(c) + public.writeLog('文件管理', '已关闭回收站功能!') + return public.returnJson(True, '已关闭回收站功能!') + else: + public.writeFile(c, 'True') + public.writeLog('文件管理', '已开启回收站功能!') + return public.returnJson(True, '已开启回收站功能!') + + def deleteDirApi(self): + path = request.form.get('path', '').encode('utf-8') + if not os.path.exists(path): + return public.returnJson(False, '指定文件不存在!') + + # 检查是否为.user.ini + if path.find('.user.ini'): + os.system("chattr -i '" + path + "'") + try: + if os.path.exists('data/recycle_bin.pl'): + if self.mvRecycleBin(path): + return public.returnJson(True, '已将文件移动到回收站!') + os.remove(path) + public.writeLog('文件管理', '删除文件成功!', (path,)) + return public.returnJson(True, '删除文件成功!') + except: + return public.returnJson(False, '删除文件失败!') + ##### ----- end ----- ### def checkFileName(self, filename): diff --git a/plugins/qbittorrent/workers/qbittorrent_worker.py b/plugins/qbittorrent/workers/qbittorrent_worker.py index 32ab2b87d..2b3e3d565 100755 --- a/plugins/qbittorrent/workers/qbittorrent_worker.py +++ b/plugins/qbittorrent/workers/qbittorrent_worker.py @@ -73,7 +73,7 @@ class downloadBT(Thread): self.dbcurr.execute('SET NAMES utf8') self.qb = self.qb() - _has_suffix = ['mp4', 'rmvb', 'flv', 'avi', 'mpg', 'mkv', 'wmw', 'avi'] + _has_suffix = ['mp4', 'rmvb', 'flv', 'avi', 'mpg', 'mkv', 'wmv', 'avi'] has_suffix = [] for x in range(len(_has_suffix)): has_suffix.append('.' + _has_suffix[x]) diff --git a/route/static/app/files.js b/route/static/app/files.js index 43ca0a663..65a905eac 100755 --- a/route/static/app/files.js +++ b/route/static/app/files.js @@ -14,7 +14,9 @@ function isDiskWidth(){ //打开回收站 function recycleBin(type){ - $.post('/files?action=Get_Recycle_bin','',function(rdata){ + $.post('/files/get_recycle_bin','',function(data){ + // console.log(rdata); + var rdata = data['data']; var body = '' switch(type){ case 1: @@ -114,7 +116,7 @@ function recycleBin(type){ break; case 4: for(var i=0;i 20) shortwebname = shortwebname.substring(0, 20) + "..."; @@ -137,7 +139,7 @@ function recycleBin(type){ case 5: for(var i=0;i 20) shortwebname = shortwebname.substring(0, 20) + "..."; @@ -185,13 +187,13 @@ function recycleBin(type){
\ '+lan.files.recycle_bin_on+'\
\ - \ - \ + \ + \
\ '+lan.files.recycle_bin_on_db+'\
\ \ - \ + \
\
\ '+lan.files.recycle_bin_ps+'\ @@ -240,7 +242,7 @@ function recycleBin(type){ $(".re-con-menu p").click(function(){ $(this).addClass("on").siblings().removeClass("on"); }) - }); + },'json'); } //去扩展名不处理 @@ -285,8 +287,8 @@ function delRecycleBin(path,obj){ //清空回收站 function CloseRecycleBin(){ - layer.confirm(lan.files.recycle_bin_close_msg,{title:lan.files.recycle_bin_close,closeBtn:2,icon:3},function(){ - var loadT = layer.msg("
"+lan.files.recycle_bin_close_the+"
",{icon:16,time:0,shade: [0.3, '#000']}); + layer.confirm('清空回收站操作会永久删除回收站中的文件,继续吗?',{title:'清空回收站',closeBtn:2,icon:3},function(){ + var loadT = layer.msg("
正在删除,请稍候...
",{icon:16,time:0,shade: [0.3, '#000']}); setTimeout(function(){ getSpeed('.myspeed'); },1000); @@ -294,19 +296,20 @@ function CloseRecycleBin(){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:5}); $("#RecycleBody").html(''); - }); + },'json'); }); } //回收站开关 -function Set_Recycle_bin(db){ - var loadT = layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); +//Set_Recycle_bin +function setRecycleBin(db){ + var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); var data = {} if(db == 1){ data = {db:db}; } - $.post('/files?action=Recycle_bin',data,function(rdata){ + $.post('/files/recycle_bin',data,function(rdata){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:5}); },'json'); @@ -386,7 +389,7 @@ function getFiles(Path) { 重命名 | \ 权限 | \ 压缩 | \ - 删除\ + 删除\ "; } else { $("#set_icon").addClass("active"); @@ -443,7 +446,7 @@ function getFiles(Path) { "+lan.files.file_menu_auth+" | \ "+lan.files.file_menu_zip+" | \ "+bodyZip+download+"\ - "+lan.files.file_menu_del+"\ + "+lan.files.file_menu_del+"\ "; } else{ @@ -497,7 +500,7 @@ function getFiles(Path) { var cutName = getCookie('cutFileName'); var isPaste = (copyName == 'null') ? cutName : copyName; if (isPaste != 'null' && isPaste != undefined) { - BarTools += ' '; + BarTools += ' '; } $("#Batch").html(''); @@ -782,11 +785,13 @@ function ShowEditMenu(){ $(this).addClass("on").siblings().removeClass("on"); }) } -//取文件名 -function GetFileName(fileNameFull) { - var pName = fileNameFull.split('/'); - return pName[pName.length - 1]; -} + +// //取文件名 +// function GetFileName(fileNameFull) { +// var pName = fileNameFull.split('/'); +// return pName[pName.length - 1]; +// } + //取磁盘 function getDisk() { var LBody = ''; @@ -902,7 +907,7 @@ function createDir(type, path) { } //删除文件 -function DeleteFile(fileName){ +function deleteFile(fileName){ layer.confirm(lan.get('recycle_bin_confirm',[fileName]),{title:lan.files.del_file,closeBtn:2,icon:3},function(){ layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); $.post('/files/delete', 'path=' + encodeURIComponent(fileName), function(rdata) { @@ -916,16 +921,16 @@ function DeleteFile(fileName){ } //删除目录 -function DeleteDir(dirName){ +function deleteDir(dirName){ layer.confirm(lan.get('recycle_bin_confirm_dir',[dirName]),{title:lan.files.del_dir,closeBtn:2,icon:3},function(){ layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/files?action=DeleteDir', 'path=' + encodeURIComponent(dirName), function(rdata) { + $.post('/files/delete_dir', 'path=' + encodeURIComponent(dirName), function(rdata) { layer.closeAll(); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); getFiles($("#DirPathPlace input").val()); - }); + },'json'); }); } //批量删除文件 @@ -1507,16 +1512,16 @@ function RClick(type,path,name){ options.items.push({text: lan.files.file_menu_del, onclick: function() {DeleteDir(path)}}); } else if(isText(type)){ - options.items.push({text: lan.files.file_menu_edit, onclick: function() {onlineEditFile(0,path)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {DeleteFile(path)}}); + options.items.push({text: lan.files.file_menu_edit, onclick: function() {onlineEditFile(0,path)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {deleteFile(path)}}); } else if(displayZip != -1){ - options.items.push({text: lan.files.file_menu_unzip, onclick: function() {UnZip(path,displayZip)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {DeleteFile(path)}}); + options.items.push({text: lan.files.file_menu_unzip, onclick: function() {UnZip(path,displayZip)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {deleteFile(path)}}); } else if(isImage(type)){ - options.items.push({text: lan.files.file_menu_img, onclick: function() {GetImage(path)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {DeleteFile(path)}}); + options.items.push({text: lan.files.file_menu_img, onclick: function() {GetImage(path)}},{text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {deleteFile(path)}}); } else{ - options.items.push({text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {DeleteFile(path)}}); + options.items.push({text: lan.files.file_menu_down, onclick: function() {GetFileBytes(path)}},{text: lan.files.file_menu_del, onclick: function() {deleteFile(path)}}); } return options; }