only show what folder we are scanning to save bandwith

This commit is contained in:
Robin Appelman 2012-02-01 15:25:00 +01:00
parent 12681e92b0
commit a69d3c3346
2 changed files with 9 additions and 10 deletions

View File

@ -347,15 +347,13 @@ $(document).ready(function() {
function scanFiles(force){ function scanFiles(force){
force=!!force; //cast to bool force=!!force; //cast to bool
var fileCount=0;
$('#scanning-message').show(); $('#scanning-message').show();
$('#fileList').remove(); $('#fileList').remove();
var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force}); var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force});
scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource); scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource);
scannerEventSource.listen('scanned',function(file){ scannerEventSource.listen('scanning',function(data){
fileCount++; $('#scan-count').text(data.count+' files scanned');
$('#scan-count').text(fileCount+' files scanned'); $('#scan-current').text(data.file+'/');
$('#scan-current').text(file);
}); });
scannerEventSource.listen('success',function(success){ scannerEventSource.listen('success',function(success){
if(success){ if(success){

View File

@ -303,7 +303,7 @@ class OC_FileCache{
* @param bool $onlyChilds * @param bool $onlyChilds
* @param OC_EventSource $enventSource * @param OC_EventSource $enventSource
*/ */
public static function scan($path,$onlyChilds,$eventSource){ public static function scan($path,$onlyChilds=false,$eventSource=false,&$count=0){
$dh=OC_Filesystem::opendir($path); $dh=OC_Filesystem::opendir($path);
$stat=OC_Filesystem::stat($path); $stat=OC_Filesystem::stat($path);
$mimetype=OC_Filesystem::getMimeType($path); $mimetype=OC_Filesystem::getMimeType($path);
@ -319,15 +319,16 @@ class OC_FileCache{
if($filename != '.' and $filename != '..'){ if($filename != '.' and $filename != '..'){
$file=$path.'/'.$filename; $file=$path.'/'.$filename;
if(OC_Filesystem::is_dir($file)){ if(OC_Filesystem::is_dir($file)){
self::scan($file,true,$eventSource); if($eventSource){
$eventSource->send('scanning',array('file'=>$file,'count'=>$count));
}
self::scan($file,true,$eventSource,$count);
}else{ }else{
$stat=OC_Filesystem::stat($file); $stat=OC_Filesystem::stat($file);
$mimetype=OC_Filesystem::getMimeType($file); $mimetype=OC_Filesystem::getMimeType($file);
$stat['mimetype']=$mimetype; $stat['mimetype']=$mimetype;
self::put($file,$stat); self::put($file,$stat);
if($eventSource){ $count++;
$eventSource->send('scanned',$file);
}
$totalSize+=$stat['size']; $totalSize+=$stat['size'];
} }
} }