Merge pull request #23576 from owncloud/background-scan-unscanned-9
[9.0] handle completely unscanned storages in the background scanner
This commit is contained in:
commit
fdab395925
|
@ -448,10 +448,26 @@ class Scanner extends BasicEmitter implements IScanner {
|
||||||
* walk over any folders that are not fully scanned yet and scan them
|
* walk over any folders that are not fully scanned yet and scan them
|
||||||
*/
|
*/
|
||||||
public function backgroundScan() {
|
public function backgroundScan() {
|
||||||
|
if (!$this->cache->inCache('')) {
|
||||||
|
$this->runBackgroundScanJob(function () {
|
||||||
|
$this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG);
|
||||||
|
}, '');
|
||||||
|
} else {
|
||||||
$lastPath = null;
|
$lastPath = null;
|
||||||
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
|
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
|
||||||
try {
|
$this->runBackgroundScanJob(function() use ($path) {
|
||||||
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
|
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
|
||||||
|
}, $path);
|
||||||
|
// FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
|
||||||
|
// to make this possible
|
||||||
|
$lastPath = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function runBackgroundScanJob(callable $callback, $path) {
|
||||||
|
try {
|
||||||
|
$callback();
|
||||||
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
|
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
|
||||||
if ($this->cacheActive) {
|
if ($this->cacheActive) {
|
||||||
$this->cache->correctFolderSize($path);
|
$this->cache->correctFolderSize($path);
|
||||||
|
@ -465,10 +481,6 @@ class Scanner extends BasicEmitter implements IScanner {
|
||||||
} catch (\OCP\Lock\LockedException $e) {
|
} catch (\OCP\Lock\LockedException $e) {
|
||||||
// skip unavailable storages
|
// 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