Merge pull request #18523 from owncloud/crazy-scanner
Prevent bkg scanner going crazy with unavailable storages (ajax/scan.php)
This commit is contained in:
commit
2f86be9ced
|
@ -49,11 +49,15 @@ foreach ($users as $user) {
|
|||
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
|
||||
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', array($listener, 'file'));
|
||||
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', array($listener, 'folder'));
|
||||
try {
|
||||
if ($force) {
|
||||
$scanner->scan($dir);
|
||||
} else {
|
||||
$scanner->backgroundScan($dir);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$eventSource->send('error', get_class($e) . ': ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$eventSource->send('done', $listener->getCount());
|
||||
|
|
|
@ -333,6 +333,9 @@ function scanFiles(force, dir, users) {
|
|||
scannerEventSource.listen('folder',function(path) {
|
||||
console.log('now scanning ' + path);
|
||||
});
|
||||
scannerEventSource.listen('error',function(message) {
|
||||
console.error('Scanner error: ', message);
|
||||
});
|
||||
scannerEventSource.listen('done',function(count) {
|
||||
scanFiles.scanning=false;
|
||||
console.log('done after ' + count + ' files');
|
||||
|
|
|
@ -416,11 +416,21 @@ class Scanner extends BasicEmitter {
|
|||
public function backgroundScan() {
|
||||
$lastPath = null;
|
||||
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
|
||||
try {
|
||||
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
|
||||
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
|
||||
if ($this->cacheActive) {
|
||||
$this->cache->correctFolderSize($path);
|
||||
}
|
||||
} catch (\OCP\Files\StorageInvalidException $e) {
|
||||
// skip unavailable storages
|
||||
} catch (\OCP\Files\StorageNotAvailableException $e) {
|
||||
// skip unavailable storages
|
||||
} catch (\OCP\Lock\LockedException $e) {
|
||||
// skip unavailable storages
|
||||
}
|
||||
// FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
|
||||
// to make this possible
|
||||
$lastPath = $path;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue