provide live feedback while scanning files

This commit is contained in:
Robin Appelman 2012-01-31 13:56:58 +01:00
parent 803f86e0fc
commit 7ff86cfebe
3 changed files with 11 additions and 3 deletions

View File

@ -347,10 +347,15 @@ $(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();
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);
scannerEventSource.listen('scanned',function(file){ scannerEventSource.listen('scanned',function(file){
console.log(file);//TODO: make this into proper feedback fileCount++;
$('#scan-count').text(fileCount+' files scanned');
$('#scan-current').text(file);
}); });
scannerEventSource.listen('success',function(success){ scannerEventSource.listen('success',function(success){
if(success){ if(success){

View File

@ -61,7 +61,10 @@
</p> </p>
</div> </div>
<div id="scanning-message"> <div id="scanning-message">
<h3>
<?php echo $l->t('Files are being scanned, please wait.');?> <span id='scan-count'></spann>
</h3>
<p> <p>
<?php echo $l->t('Files are being scanned, please wait.');?> <?php echo $l->t('Current scanning');?> <span id='scan-current'></spann>
</p> </p>
</div> </div>

View File

@ -290,7 +290,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){//PROBLEM due to the order things are added, all parents are -1 public static function scan($path,$onlyChilds,$eventSource){
$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);