]> source.dussan.org Git - nextcloud-server.git/commitdiff
send more progress updates when scanning large folders
authorRobin Appelman <icewind@owncloud.com>
Sat, 31 Mar 2012 14:24:53 +0000 (16:24 +0200)
committerRobin Appelman <icewind@owncloud.com>
Sat, 31 Mar 2012 14:24:53 +0000 (16:24 +0200)
lib/filecache.php

index 86d865ed9f3b6c2038e1047e16d6dee99722aa59..59b0fb1b503980ec72b11fb5a2bd321278c55cbb 100644 (file)
@@ -469,6 +469,10 @@ class OC_FileCache{
         * @param string root (optionak)
         */
        public static function scan($path,$eventSource=false,&$count=0,$root=''){
+               if($eventSource){
+                       $eventSource->send('scanning',array('file'=>$path,'count'=>$count));
+               }
+               $lastSend=$count;
                if(!$root){
                        $view=OC_Filesystem::getView();
                }else{
@@ -482,13 +486,15 @@ class OC_FileCache{
                                if($filename != '.' and $filename != '..'){
                                        $file=$path.'/'.$filename;
                                        if($view->is_dir($file.'/')){
-                                               if($eventSource){
-                                                       $eventSource->send('scanning',array('file'=>$file,'count'=>$count));
-                                               }
                                                self::scan($file,$eventSource,$count,$root);
                                        }else{
                                                $totalSize+=self::scanFile($file,$root);
                                                $count++;
+                                               if($count>$lastSend+25){
+                                                       if($eventSource){
+                                                               $eventSource->send('scanning',array('file'=>$path,'count'=>$count));
+                                                       }
+                                               }
                                        }
                                }
                        }