|
|
|
@ -52,7 +52,7 @@ class files_api: |
|
|
|
|
if not os.path.exists(filename): |
|
|
|
|
return '' |
|
|
|
|
response = make_response(send_from_directory( |
|
|
|
|
os.path.dirname(filename), os.path.basename(filename), as_attachment=True)) |
|
|
|
|
os.path.dirname(filename).encode('utf-8'), os.path.basename(filename).encode('utf-8'), as_attachment=True)) |
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
def zipApi(self): |
|
|
|
@ -398,69 +398,71 @@ done |
|
|
|
|
key = key.encode('utf-8') |
|
|
|
|
filename = path + '/' + key |
|
|
|
|
if not self.checkDir(filename): |
|
|
|
|
return public.returnJson(False,'FILE_DANGER'); |
|
|
|
|
return public.returnJson(False, 'FILE_DANGER') |
|
|
|
|
os.system('chmod -R ' + access + " '" + filename + "'") |
|
|
|
|
os.system('chown -R '+user+':'+user+" '"+filename+"'") |
|
|
|
|
os.system('chown -R ' + user + ':' + |
|
|
|
|
user + " '" + filename + "'") |
|
|
|
|
except: |
|
|
|
|
continue; |
|
|
|
|
continue |
|
|
|
|
public.writeLog('文件管理', '批量设置权限成功!') |
|
|
|
|
return public.returnJson(True, '批量设置权限成功!') |
|
|
|
|
else: |
|
|
|
|
import shutil |
|
|
|
|
isRecyle = os.path.exists('data/recycle_bin.pl') |
|
|
|
|
data = json.loads(data) |
|
|
|
|
l = len(data); |
|
|
|
|
i = 0; |
|
|
|
|
l = len(data) |
|
|
|
|
i = 0 |
|
|
|
|
for key in data: |
|
|
|
|
try: |
|
|
|
|
filename = path + '/' + key.encode('utf-8') |
|
|
|
|
topath = filename; |
|
|
|
|
topath = filename |
|
|
|
|
if not os.path.exists(filename): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
i += 1; |
|
|
|
|
public.writeSpeed(key,i,l); |
|
|
|
|
i += 1 |
|
|
|
|
public.writeSpeed(key, i, l) |
|
|
|
|
if os.path.isdir(filename): |
|
|
|
|
if not self.checkDir(filename): |
|
|
|
|
return public.returnJson(False,'请不要花样作死!'); |
|
|
|
|
return public.returnJson(False, '请不要花样作死!') |
|
|
|
|
if isRecyle: |
|
|
|
|
self.mvRecycleBin(topath) |
|
|
|
|
else: |
|
|
|
|
shutil.rmtree(filename) |
|
|
|
|
else: |
|
|
|
|
if key == '.user.ini': |
|
|
|
|
os.system('which chattr && chattr -i ' + filename); |
|
|
|
|
os.system('which chattr && chattr -i ' + filename) |
|
|
|
|
if isRecyle: |
|
|
|
|
self.mvRecycleBin(topath) |
|
|
|
|
else: |
|
|
|
|
os.remove(filename) |
|
|
|
|
except: |
|
|
|
|
continue; |
|
|
|
|
public.writeSpeed(None,0,0); |
|
|
|
|
continue |
|
|
|
|
public.writeSpeed(None, 0, 0) |
|
|
|
|
public.writeLog('文件管理', '批量删除成功!') |
|
|
|
|
return public.returnJson(True, '批量删除成功!') |
|
|
|
|
|
|
|
|
|
def checkExistsFilesApi(self): |
|
|
|
|
dfile = request.form.get('dfile', '').encode('utf-8') |
|
|
|
|
filename = request.form.get('filename', '').encode('utf-8') |
|
|
|
|
data = []; |
|
|
|
|
filesx = []; |
|
|
|
|
data = [] |
|
|
|
|
filesx = [] |
|
|
|
|
if filename == '': |
|
|
|
|
filesx = json.loads(session['selected']['data']); |
|
|
|
|
filesx = json.loads(session['selected']['data']) |
|
|
|
|
else: |
|
|
|
|
filesx.append(filename); |
|
|
|
|
filesx.append(filename) |
|
|
|
|
|
|
|
|
|
print filesx |
|
|
|
|
|
|
|
|
|
for fn in filesx: |
|
|
|
|
if fn == '.': continue |
|
|
|
|
filename = dfile + '/' + fn; |
|
|
|
|
if fn == '.': |
|
|
|
|
continue |
|
|
|
|
filename = dfile + '/' + fn |
|
|
|
|
if os.path.exists(filename): |
|
|
|
|
tmp = {} |
|
|
|
|
stat = os.stat(filename) |
|
|
|
|
tmp['filename'] = fn |
|
|
|
|
tmp['size'] = os.path.getsize(filename); |
|
|
|
|
tmp['mtime'] = str(int(stat.st_mtime)); |
|
|
|
|
tmp['size'] = os.path.getsize(filename) |
|
|
|
|
tmp['mtime'] = str(int(stat.st_mtime)) |
|
|
|
|
data.append(tmp) |
|
|
|
|
return public.returnJson(True, 'ok', data) |
|
|
|
|
|
|
|
|
@ -470,17 +472,18 @@ done |
|
|
|
|
# filename = request.form.get('filename', '').encode('utf-8') |
|
|
|
|
import shutil |
|
|
|
|
if not self.checkDir(path): |
|
|
|
|
return public.returnJson(False,'请不要花样作死!'); |
|
|
|
|
i = 0; |
|
|
|
|
return public.returnJson(False, '请不要花样作死!') |
|
|
|
|
i = 0 |
|
|
|
|
myfiles = json.loads(session['selected']['data']) |
|
|
|
|
l = len(myfiles); |
|
|
|
|
l = len(myfiles) |
|
|
|
|
if stype == '1': |
|
|
|
|
for key in myfiles: |
|
|
|
|
i += 1 |
|
|
|
|
public.writeSpeed(key,i,l); |
|
|
|
|
public.writeSpeed(key, i, l) |
|
|
|
|
try: |
|
|
|
|
|
|
|
|
|
sfile = session['selected']['path'] + '/' + key.encode('utf-8') |
|
|
|
|
sfile = session['selected'][ |
|
|
|
|
'path'] + '/' + key.encode('utf-8') |
|
|
|
|
dfile = path + '/' + key.encode('utf-8') |
|
|
|
|
|
|
|
|
|
if os.path.isdir(sfile): |
|
|
|
@ -490,28 +493,31 @@ done |
|
|
|
|
stat = os.stat(sfile) |
|
|
|
|
os.chown(dfile, stat.st_uid, stat.st_gid) |
|
|
|
|
except: |
|
|
|
|
continue; |
|
|
|
|
msg = public.getInfo('从[{1}]批量复制到[{2}]成功',(session['selected']['path'],path,)) |
|
|
|
|
continue |
|
|
|
|
msg = public.getInfo('从[{1}]批量复制到[{2}]成功', |
|
|
|
|
(session['selected']['path'], path,)) |
|
|
|
|
public.writeLog('文件管理', msg) |
|
|
|
|
else: |
|
|
|
|
for key in myfiles: |
|
|
|
|
try: |
|
|
|
|
i += 1 |
|
|
|
|
public.writeSpeed(key,i,l); |
|
|
|
|
public.writeSpeed(key, i, l) |
|
|
|
|
|
|
|
|
|
sfile = session['selected']['path'] + '/' + key.encode('utf-8') |
|
|
|
|
sfile = session['selected'][ |
|
|
|
|
'path'] + '/' + key.encode('utf-8') |
|
|
|
|
dfile = path + '/' + key.encode('utf-8') |
|
|
|
|
|
|
|
|
|
shutil.move(sfile, dfile) |
|
|
|
|
except: |
|
|
|
|
continue; |
|
|
|
|
msg = public.getInfo('从[{1}]批量移动到[{2}]成功', (session['selected']['path'],path,)) |
|
|
|
|
continue |
|
|
|
|
msg = public.getInfo('从[{1}]批量移动到[{2}]成功', |
|
|
|
|
(session['selected']['path'], path,)) |
|
|
|
|
public.writeLog('文件管理', msg) |
|
|
|
|
public.writeSpeed(None,0,0); |
|
|
|
|
public.writeSpeed(None, 0, 0) |
|
|
|
|
errorCount = len(myfiles) - i |
|
|
|
|
del(session['selected']) |
|
|
|
|
msg = public.getInfo('批量操作成功[{1}],失败[{2}]', (str(i), str(errorCount))) |
|
|
|
|
return public.returnJson(True, msg); |
|
|
|
|
return public.returnJson(True, msg) |
|
|
|
|
|
|
|
|
|
def copyFileApi(self): |
|
|
|
|
sfile = request.form.get('sfile', '').encode('utf-8') |
|
|
|
@ -534,16 +540,15 @@ done |
|
|
|
|
except: |
|
|
|
|
return public.returnJson(False, '文件复制失败!') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##### ----- end ----- ### |
|
|
|
|
|
|
|
|
|
def copyDir(self, sfile, dfile): |
|
|
|
|
|
|
|
|
|
if not os.path.exists(sfile): |
|
|
|
|
return public.returnJson(False,'指定目录不存在!'); |
|
|
|
|
return public.returnJson(False, '指定目录不存在!') |
|
|
|
|
|
|
|
|
|
if os.path.exists(dfile): |
|
|
|
|
return public.returnJson(False,'指定目录已存在!'); |
|
|
|
|
return public.returnJson(False, '指定目录已存在!') |
|
|
|
|
import shutil |
|
|
|
|
try: |
|
|
|
|
shutil.copytree(sfile, dfile) |
|
|
|
|