only show files in the filebrowser that we can actually read.

in the (rare) case that there are unreadable files show an error since it's probably a case of incorrect premissions set by someone.
This commit is contained in:
Robin Appelman 2011-01-22 02:56:16 +01:00
parent 15d15104d4
commit 066ca70890
3 changed files with 22 additions and 4 deletions

View File

@ -54,7 +54,7 @@ if($arguments['action']){
break; break;
case 'getfiles': case 'getfiles':
$max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize'))); $max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
$files=OC_FILES::getdirectorycontent($arguments['dir']); $files=OC_FILES::getDirectoryContent($arguments['dir']);
$files['__max_upload']=$max_upload; $files['__max_upload']=$max_upload;
echo json_encode($files); echo json_encode($files);
break; break;

View File

@ -130,11 +130,29 @@ OC_FILES.browser.files.show=function(parent,fileList){
} }
} }
//add the files that arent in the list yet //add the files that arent in the list yet
var unreadableFiles=[];
for(name in fileList){ for(name in fileList){
file=fileList[name]; file=fileList[name];
if(file.readable){
if(!OC_FILES.browser.files.fileNodes[file.name]){ if(!OC_FILES.browser.files.fileNodes[file.name]){
OC_FILES.browser.files.add(file.name,file.type,file.size,file.date,file.mime); OC_FILES.browser.files.add(file.name,file.type,file.size,file.date,file.mime);
} }
}else if(file.name){
unreadableFiles.push(file);
}
}
if(unreadableFiles.length>0){
var message=unreadableFiles.length+" unreadable files detected:\n";
var first=true;
unreadableFiles.foreach(function(item){
if(!first){
message+=', ';
}
first=false;
message+=item.name;
});
message+="\nPlease check the file premissions";
alert(message);
} }
} }
} }

View File

@ -47,7 +47,7 @@ OC_FILES.getdirectorycontent_parse=function(req){
for(var name in json){ for(var name in json){
if(name!='__max_upload'){ if(name!='__max_upload'){
var file=new Array(); var file=new Array();
var attributes=Array('size','name','type','directory','date','mime'); var attributes=Array('size','name','type','directory','date','mime','writable','readable');
for(var i in attributes){ for(var i in attributes){
var attributeName=attributes[i]; var attributeName=attributes[i];
file[attributeName]=json[name][attributeName]; file[attributeName]=json[name][attributeName];