diff --git a/class/core/file_api.py b/class/core/file_api.py
index 7c03752b1..225d07987 100755
--- a/class/core/file_api.py
+++ b/class/core/file_api.py
@@ -163,8 +163,19 @@ class file_api:
except:
return public.returnJson(False, '删除文件失败!')
+ def getAccess(self, filename):
+ data = {}
+ try:
+ stat = os.stat(filename)
+ data['chmod'] = str(oct(stat.st_mode)[-3:])
+ data['chown'] = pwd.getpwuid(stat.st_uid).pw_name
+ except:
+ data['chmod'] = 755
+ data['chown'] = 'www'
+ return data
+
# 计算文件数量
- def getFilesCount(self, path, search):
+ def getCount(self, path, search):
i = 0
for name in os.listdir(path):
if search:
@@ -181,7 +192,7 @@ class file_api:
filenames = []
info = {}
- info['count'] = self.getFilesCount(path, search)
+ info['count'] = self.getCount(path, search)
info['row'] = page_size
info['p'] = page
info['tojs'] = 'getFiles'
diff --git a/route/files.py b/route/files.py
index 1a52c81ab..ac63bd502 100644
--- a/route/files.py
+++ b/route/files.py
@@ -63,6 +63,13 @@ def delete():
return file_api.file_api().delete(path)
+@files.route('/file_access', methods=['POST'])
+def fileAccess():
+ filename = request.form.get('filename', '').encode('utf-8')
+ data = file_api.file_api().getAccess(filename)
+ return public.getJson(data)
+
+
@files.route('/get_dir', methods=['POST'])
def getDir():
path = request.form.get('path', '').encode('utf-8')
diff --git a/static/app/files.js b/static/app/files.js
index e7f536300..1c4e6ee2c 100755
--- a/static/app/files.js
+++ b/static/app/files.js
@@ -378,7 +378,7 @@ function getFiles(Path) {
"+lan.files.file_menu_copy+" | \
"+lan.files.file_menu_mv+" | \
"+lan.files.file_menu_rename+" | \
- "+lan.files.file_menu_auth+" | \
+ "+lan.files.file_menu_auth+" | \
"+lan.files.file_menu_zip+" | \
"+lan.files.file_menu_del+"\
";
@@ -433,7 +433,7 @@ function getFiles(Path) {
"+lan.files.file_menu_copy+" | \
"+lan.files.file_menu_mv+" | \
"+lan.files.file_menu_rename+" | \
- "+lan.files.file_menu_auth+" | \
+ "+lan.files.file_menu_auth+" | \
"+lan.files.file_menu_zip+" | \
"+bodyZip+download+"\
"+lan.files.file_menu_del+"\
@@ -677,7 +677,7 @@ function Batch(type,access){
}
if(type == 3 && access == undefined){
- SetChmod(0,lan.files.all);
+ setChmod(0,lan.files.all);
return;
}
@@ -1365,7 +1365,7 @@ function UploadFiles(){
}
//设置权限
-function SetChmod(action,fileName){
+function setChmod(action,fileName){
if(action == 1){
var chmod = $("#access").val();
var chown = $("#chown").val();
@@ -1381,9 +1381,9 @@ function SetChmod(action,fileName){
return;
}
- var toExec = fileName == lan.files.all?'Batch(3,1)':'SetChmod(1,\''+fileName+'\')';
-
- $.post('/files?action=GetFileAccess','filename='+encodeURIComponent(fileName),function(rdata){
+ var toExec = fileName == lan.files.all?'Batch(3,1)':'setChmod(1,\''+fileName+'\')';
+ $.post('/files/file_access','filename='+encodeURIComponent(fileName),function(rdata){
+ console.log(rdata);
layer.open({
type:1,
closeBtn: 2,
@@ -1439,10 +1439,9 @@ function SetChmod(action,fileName){
onacc += access;
}
$("#access").val(onacc);
-
});
- })
-
+
+ },'json');
}
function onAccess(){
@@ -1494,7 +1493,7 @@ function RClick(type,path,name){
{text: lan.files.file_menu_copy, onclick: function() {CopyFile(path)}},
{text: lan.files.file_menu_mv, onclick: function() {CutFile(path)}},
{text: lan.files.file_menu_rename, onclick: function() {ReName(0,name)}},
- {text: lan.files.file_menu_auth, onclick: function() {SetChmod(0,path)}},
+ {text: lan.files.file_menu_auth, onclick: function() {setChmod(0,path)}},
{text: lan.files.file_menu_zip, onclick: function() {Zip(path)}}
]};