summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-12-02 17:09:43 +0000
committerGitHub <noreply@github.com>2021-12-02 17:09:43 +0000
commit6b3c7037946bf63b5bd684c7f1ee3e72ea0e6148 (patch)
tree5d25af0f2d7f6a775034b3b149637f522f59d983 /lib
parent7acb438e428e5b0b3a79c2b7ce5a4283b0e805eb (diff)
parente95745c074c6d04cd271706a836eccbcc674cca8 (diff)
downloadnextcloud-server-6b3c7037946bf63b5bd684c7f1ee3e72ea0e6148.tar.gz
nextcloud-server-6b3c7037946bf63b5bd684c7f1ee3e72ea0e6148.zip
Merge pull request #29735 from nextcloud/background-scan-one-by-one
find users for background scan one by one
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/Scanner.php37
-rw-r--r--lib/private/Files/Utils/Scanner.php4
-rw-r--r--lib/public/Files/IHomeStorage.php4
-rw-r--r--lib/public/Files/Storage.php3
-rw-r--r--lib/public/Files/Storage/IDisableEncryptionStorage.php2
-rw-r--r--lib/public/Files/Storage/IStorage.php3
6 files changed, 35 insertions, 18 deletions
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index bdefca01f6f..bd8db2c8a12 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -37,6 +37,7 @@ namespace OC\Files\Cache;
use Doctrine\DBAL\Exception;
use OC\Files\Filesystem;
+use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\Encoding;
use OC\Hooks\BasicEmitter;
use OCP\Files\Cache\IScanner;
@@ -509,19 +510,31 @@ class Scanner extends BasicEmitter implements IScanner {
* walk over any folders that are not fully scanned yet and scan them
*/
public function backgroundScan() {
- if (!$this->cache->inCache('')) {
- $this->runBackgroundScanJob(function () {
- $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG);
- }, '');
+ if ($this->storage->instanceOfStorage(Jail::class)) {
+ // for jail storage wrappers (shares, groupfolders) we run the background scan on the source storage
+ // this is mainly done because the jail wrapper doesn't implement `getIncomplete` (because it would be inefficient).
+ //
+ // Running the scan on the source storage might scan more than "needed", but the unscanned files outside the jail will
+ // have to be scanned at some point anyway.
+ $unJailedScanner = $this->storage->getUnjailedStorage()->getScanner();
+ $unJailedScanner->backgroundScan();
} else {
- $lastPath = null;
- while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
- $this->runBackgroundScanJob(function () use ($path) {
- $this->scan($path, self::SCAN_RECURSIVE_INCOMPLETE, self::REUSE_ETAG | self::REUSE_SIZE);
- }, $path);
- // FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
- // to make this possible
- $lastPath = $path;
+ if (!$this->cache->inCache('')) {
+ // if the storage isn't in the cache yet, just scan the root completely
+ $this->runBackgroundScanJob(function () {
+ $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG);
+ }, '');
+ } else {
+ $lastPath = null;
+ // find any path marked as unscanned and run the scanner until no more paths are unscanned (or we get stuck)
+ while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
+ $this->runBackgroundScanJob(function () use ($path) {
+ $this->scan($path, self::SCAN_RECURSIVE_INCOMPLETE, self::REUSE_ETAG | self::REUSE_SIZE);
+ }, $path);
+ // FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
+ // to make this possible
+ $lastPath = $path;
+ }
}
}
}
diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php
index faeb31db8cc..2e5a25a355b 100644
--- a/lib/private/Files/Utils/Scanner.php
+++ b/lib/private/Files/Utils/Scanner.php
@@ -166,10 +166,6 @@ class Scanner extends PublicEmitter {
continue;
}
- // don't scan received local shares, these can be scanned when scanning the owner's storage
- if ($storage->instanceOfStorage(SharedStorage::class)) {
- continue;
- }
$scanner = $storage->getScanner();
$this->attachListener($mount);
diff --git a/lib/public/Files/IHomeStorage.php b/lib/public/Files/IHomeStorage.php
index 0f10d599148..7eb3ffc4a24 100644
--- a/lib/public/Files/IHomeStorage.php
+++ b/lib/public/Files/IHomeStorage.php
@@ -26,10 +26,12 @@
namespace OCP\Files;
+use OCP\Files\Storage\IStorage;
+
/**
* Interface IHomeStorage
*
* @since 7.0.0
*/
-interface IHomeStorage {
+interface IHomeStorage extends IStorage {
}
diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php
index afc735c7829..0a1a504b137 100644
--- a/lib/public/Files/Storage.php
+++ b/lib/public/Files/Storage.php
@@ -368,9 +368,12 @@ interface Storage extends IStorage {
/**
* Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
*
+ * @template T of IStorage
* @param string $class
+ * @psalm-param class-string<T> $class
* @return bool
* @since 7.0.0
+ * @psalm-assert-if-true T $this
*/
public function instanceOfStorage($class);
diff --git a/lib/public/Files/Storage/IDisableEncryptionStorage.php b/lib/public/Files/Storage/IDisableEncryptionStorage.php
index 11d71549cac..7b70aa3e47f 100644
--- a/lib/public/Files/Storage/IDisableEncryptionStorage.php
+++ b/lib/public/Files/Storage/IDisableEncryptionStorage.php
@@ -28,5 +28,5 @@ namespace OCP\Files\Storage;
*
* @since 16.0.0
*/
-interface IDisableEncryptionStorage {
+interface IDisableEncryptionStorage extends IStorage {
}
diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php
index 21272f216c7..f42eb81bfec 100644
--- a/lib/public/Files/Storage/IStorage.php
+++ b/lib/public/Files/Storage/IStorage.php
@@ -356,9 +356,12 @@ interface IStorage {
/**
* Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
*
+ * @template T of IStorage
* @param string $class
+ * @psalm-param class-string<T> $class
* @return bool
* @since 9.0.0
+ * @psalm-assert-if-true T $this
*/
public function instanceOfStorage($class);