|
38 | 38 |
|
39 | 39 | use Doctrine\DBAL\Exception; |
40 | 40 | use OC\Files\Filesystem; |
| 41 | +use OC\Files\Storage\Wrapper\Jail; |
41 | 42 | use OC\Files\Storage\Wrapper\Encoding; |
42 | 43 | use OC\Hooks\BasicEmitter; |
43 | 44 | use OCP\Files\Cache\IScanner; |
@@ -510,19 +511,31 @@ public static function isPartialFile($file) { |
510 | 511 | * walk over any folders that are not fully scanned yet and scan them |
511 | 512 | */ |
512 | 513 | public function backgroundScan() { |
513 | | - if (!$this->cache->inCache('')) { |
514 | | - $this->runBackgroundScanJob(function () { |
515 | | - $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG); |
516 | | - }, ''); |
| 514 | + if ($this->storage->instanceOfStorage(Jail::class)) { |
| 515 | + // for jail storage wrappers (shares, groupfolders) we run the background scan on the source storage |
| 516 | + // this is mainly done because the jail wrapper doesn't implement `getIncomplete` (because it would be inefficient). |
| 517 | + // |
| 518 | + // Running the scan on the source storage might scan more than "needed", but the unscanned files outside the jail will |
| 519 | + // have to be scanned at some point anyway. |
| 520 | + $unJailedScanner = $this->storage->getUnjailedStorage()->getScanner(); |
| 521 | + $unJailedScanner->backgroundScan(); |
517 | 522 | } else { |
518 | | - $lastPath = null; |
519 | | - while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) { |
520 | | - $this->runBackgroundScanJob(function () use ($path) { |
521 | | - $this->scan($path, self::SCAN_RECURSIVE_INCOMPLETE, self::REUSE_ETAG | self::REUSE_SIZE); |
522 | | - }, $path); |
523 | | - // FIXME: this won't proceed with the next item, needs revamping of getIncomplete() |
524 | | - // to make this possible |
525 | | - $lastPath = $path; |
| 523 | + if (!$this->cache->inCache('')) { |
| 524 | + // if the storage isn't in the cache yet, just scan the root completely |
| 525 | + $this->runBackgroundScanJob(function () { |
| 526 | + $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG); |
| 527 | + }, ''); |
| 528 | + } else { |
| 529 | + $lastPath = null; |
| 530 | + // find any path marked as unscanned and run the scanner until no more paths are unscanned (or we get stuck) |
| 531 | + while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) { |
| 532 | + $this->runBackgroundScanJob(function () use ($path) { |
| 533 | + $this->scan($path, self::SCAN_RECURSIVE_INCOMPLETE, self::REUSE_ETAG | self::REUSE_SIZE); |
| 534 | + }, $path); |
| 535 | + // FIXME: this won't proceed with the next item, needs revamping of getIncomplete() |
| 536 | + // to make this possible |
| 537 | + $lastPath = $path; |
| 538 | + } |
526 | 539 | } |
527 | 540 | } |
528 | 541 | } |
|
0 commit comments