summaryrefslogtreecommitdiffstats
path: root/lib/private/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-03-24 15:17:13 +0100
committerRobin Appelman <icewind@owncloud.com>2016-03-24 17:16:21 +0100
commit6485d95c5ac830004e1db69e8478bb0e99309890 (patch)
tree712cec5326adae4cca0bd60188282125ec84602c /lib/private/files
parenta7e7f5e18098ff0f536e58a7e1e5dfdc825e9086 (diff)
downloadnextcloud-server-6485d95c5ac830004e1db69e8478bb0e99309890.tar.gz
nextcloud-server-6485d95c5ac830004e1db69e8478bb0e99309890.zip
handle completely unscanned storages in the background scanner
Diffstat (limited to 'lib/private/files')
-rw-r--r--lib/private/files/cache/scanner.php50
1 files changed, 31 insertions, 19 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 0a207de7b64..5ca32548fe0 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -448,26 +448,38 @@ class Scanner extends BasicEmitter implements IScanner {
* walk over any folders that are not fully scanned yet and scan them
*/
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\Files\ForbiddenException $e) {
- // skip forbidden storages
- } catch (\OCP\Lock\LockedException $e) {
- // skip unavailable storages
+ if (!$this->cache->inCache('')) {
+ $this->runBackgroundScanJob(function () {
+ $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG);
+ }, '');
+ } else {
+ $lastPath = null;
+ while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
+ $this->runBackgroundScanJob(function() use ($path) {
+ $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));
+ if ($this->cacheActive) {
+ $this->cache->correctFolderSize($path);
}
- // FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
- // to make this possible
- $lastPath = $path;
+ } catch (\OCP\Files\StorageInvalidException $e) {
+ // skip unavailable storages
+ } catch (\OCP\Files\StorageNotAvailableException $e) {
+ // skip unavailable storages
+ } catch (\OCP\Files\ForbiddenException $e) {
+ // skip forbidden storages
+ } catch (\OCP\Lock\LockedException $e) {
+ // skip unavailable storages
}
}