From 524e3686a0da79493a6048d8d92b7bbb0982ec08 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 10 Nov 2011 16:40:09 +0100 Subject: tell the user when the files are being scanned --- files/ajax/scan.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 files/ajax/scan.php (limited to 'files/ajax/scan.php') diff --git a/files/ajax/scan.php b/files/ajax/scan.php new file mode 100644 index 00000000000..dec949a819b --- /dev/null +++ b/files/ajax/scan.php @@ -0,0 +1,16 @@ + array( "done" => true))); +}else{ + OC_JSON::success(array("data" => array( "done" => false))); +} \ No newline at end of file -- cgit v1.2.3 From ffecc3e4341102714a89ab6b5643c666c1feb0ee Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 30 Jan 2012 23:32:55 +0100 Subject: start of proper feedback during filessytem scan --- files/ajax/scan.php | 11 +++++++---- files/js/files.js | 12 ++++++++---- lib/filecache.php | 6 ++++-- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'files/ajax/scan.php') diff --git a/files/ajax/scan.php b/files/ajax/scan.php index dec949a819b..01236c83da1 100644 --- a/files/ajax/scan.php +++ b/files/ajax/scan.php @@ -2,15 +2,18 @@ require_once '../../lib/base.php'; +$eventSource=new OC_EventSource(); + $force=isset($_GET['force']) and $_GET['force']=='true'; $checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true'; //create the file cache if necesary if($force or !OC_FileCache::inCache('')){ if(!$checkOnly){ - OC_FileCache::scan(''); + OC_FileCache::scan('',false,$eventSource); } - OC_JSON::success(array("data" => array( "done" => true))); + $eventSource->send('success',true); }else{ - OC_JSON::success(array("data" => array( "done" => false))); -} \ No newline at end of file + $eventSource->send('success',false); +} +$eventSource->close(); \ No newline at end of file diff --git a/files/js/files.js b/files/js/files.js index 649f193aa2d..28259606cea 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -348,13 +348,17 @@ $(document).ready(function() { function scanFiles(force){ force=!!force; //cast to bool $('#scanning-message').show(); - $.get(OC.filePath('files','ajax','scan.php'),{force:force}, function(response) { - if(response && response.data && response.data.done){ + var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force}); + scannerEventSource.listen('scanned',function(file){ + console.log(file);//TODO: make this into proper feedback + }); + scannerEventSource.listen('success',function(success){ + if(success){ window.location.reload(); }else{ - alert('error') + alert('error while scanning'); } - }, "json"); + }); } function boolOperationFinished(data, callback) { diff --git a/lib/filecache.php b/lib/filecache.php index 928fc02e669..4e458ad929a 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -288,8 +288,9 @@ class OC_FileCache{ * recursively scan the filesystem and fill the cache * @param string $path * @param bool $onlyChilds + * @param OC_EventSource $enventSource */ - public static function scan($path,$onlyChilds=false){//PROBLEM due to the order things are added, all parents are -1 + public static function scan($path,$onlyChilds,$eventSource){//PROBLEM due to the order things are added, all parents are -1 $dh=OC_Filesystem::opendir($path); $stat=OC_Filesystem::stat($path); $mimetype=OC_Filesystem::getMimeType($path); @@ -305,12 +306,13 @@ class OC_FileCache{ if($filename != '.' and $filename != '..'){ $file=$path.'/'.$filename; if(OC_Filesystem::is_dir($file)){ - self::scan($file,true); + self::scan($file,true,$eventSource); }else{ $stat=OC_Filesystem::stat($file); $mimetype=OC_Filesystem::getMimeType($file); $stat['mimetype']=$mimetype; self::put($file,$stat); + $eventSource->send('scanned',$file); $totalSize+=$stat['size']; } } -- cgit v1.2.3 From df67c35017d8794a4b1c83fd4e41658b2e6d0e75 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 31 Jan 2012 16:12:38 +0100 Subject: some fixes to scanning --- db_structure.xml | 9 +++++++++ files/ajax/scan.php | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'files/ajax/scan.php') diff --git a/db_structure.xml b/db_structure.xml index 13d5732a8d5..5ef22b595cf 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -81,6 +81,15 @@ true 512 + + + user + text + + + true + 64 + size diff --git a/files/ajax/scan.php b/files/ajax/scan.php index 01236c83da1..37ce7ab71f0 100644 --- a/files/ajax/scan.php +++ b/files/ajax/scan.php @@ -2,17 +2,25 @@ require_once '../../lib/base.php'; -$eventSource=new OC_EventSource(); +set_time_limit(0);//scanning can take ages $force=isset($_GET['force']) and $_GET['force']=='true'; $checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true'; +if(!$checkOnly){ + $eventSource=new OC_EventSource(); +} + + //create the file cache if necesary if($force or !OC_FileCache::inCache('')){ if(!$checkOnly){ OC_FileCache::scan('',false,$eventSource); + $eventSource->send('success',true); + }else{ + OC_JSON::success(array('data'=>array('done'=>true))); + exit; } - $eventSource->send('success',true); }else{ $eventSource->send('success',false); } -- cgit v1.2.3 From f1c5dce75c5f1bc2c9d7022a8b43577a3dec9629 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 31 Jan 2012 16:33:16 +0100 Subject: dont try to use something that isn't there --- files/ajax/scan.php | 6 +++++- lib/filecache.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'files/ajax/scan.php') diff --git a/files/ajax/scan.php b/files/ajax/scan.php index 37ce7ab71f0..f7e75d5f8ba 100644 --- a/files/ajax/scan.php +++ b/files/ajax/scan.php @@ -22,6 +22,10 @@ if($force or !OC_FileCache::inCache('')){ exit; } }else{ - $eventSource->send('success',false); + if(isset($eventSource)){ + $eventSource->send('success',false); + }else{ + exit; + } } $eventSource->close(); \ No newline at end of file diff --git a/lib/filecache.php b/lib/filecache.php index 689680624a4..b4cafe8b311 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -325,7 +325,9 @@ class OC_FileCache{ $mimetype=OC_Filesystem::getMimeType($file); $stat['mimetype']=$mimetype; self::put($file,$stat); - $eventSource->send('scanned',$file); + if($eventSource){ + $eventSource->send('scanned',$file); + } $totalSize+=$stat['size']; } } -- cgit v1.2.3 From 7c00aedc37cf039ec23c54429d5188ab7d219b7e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 5 Feb 2012 01:23:04 +0100 Subject: some improvements in file scanning --- files/ajax/scan.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'files/ajax/scan.php') diff --git a/files/ajax/scan.php b/files/ajax/scan.php index f7e75d5f8ba..565275911b4 100644 --- a/files/ajax/scan.php +++ b/files/ajax/scan.php @@ -15,13 +15,19 @@ if(!$checkOnly){ //create the file cache if necesary if($force or !OC_FileCache::inCache('')){ if(!$checkOnly){ - OC_FileCache::scan('',false,$eventSource); + OC_DB::beginTransaction(); + OC_FileCache::scan('',$eventSource); + OC_DB::commit(); $eventSource->send('success',true); }else{ OC_JSON::success(array('data'=>array('done'=>true))); exit; } }else{ + if($checkOnly){ + OC_JSON::success(array('data'=>array('done'=>false))); + exit; + } if(isset($eventSource)){ $eventSource->send('success',false); }else{ -- cgit v1.2.3