aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-02-07 10:06:32 +0100
committerGitHub <noreply@github.com>2024-02-07 10:06:32 +0100
commit5ea69768b08a77606cdf2db6f3a530cf017a1eeb (patch)
tree73612aee39932509692d66d7b1880d89e50a7e0f
parent840e8fcb772f15e815b043c43678fa64512213e6 (diff)
parent3066687c7da2835e8b14e5b73e3a9a0987f236c7 (diff)
downloadnextcloud-server-5ea69768b08a77606cdf2db6f3a530cf017a1eeb.tar.gz
nextcloud-server-5ea69768b08a77606cdf2db6f3a530cf017a1eeb.zip
Merge pull request #41015 from nextcloud/background-scan-catch-storage-error
continue background scanning different storages if one fails
-rw-r--r--lib/private/Files/Utils/Scanner.php50
1 files changed, 27 insertions, 23 deletions
diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php
index 226e5462b34..6348427cb3b 100644
--- a/lib/private/Files/Utils/Scanner.php
+++ b/lib/private/Files/Utils/Scanner.php
@@ -156,33 +156,37 @@ class Scanner extends PublicEmitter {
public function backgroundScan($dir) {
$mounts = $this->getMounts($dir);
foreach ($mounts as $mount) {
- $storage = $mount->getStorage();
- if (is_null($storage)) {
- continue;
- }
+ try {
+ $storage = $mount->getStorage();
+ if (is_null($storage)) {
+ continue;
+ }
- // don't bother scanning failed storages (shortcut for same result)
- if ($storage->instanceOfStorage(FailedStorage::class)) {
- continue;
- }
+ // don't bother scanning failed storages (shortcut for same result)
+ if ($storage->instanceOfStorage(FailedStorage::class)) {
+ continue;
+ }
- $scanner = $storage->getScanner();
- $this->attachListener($mount);
+ $scanner = $storage->getScanner();
+ $this->attachListener($mount);
- $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) {
- $this->triggerPropagator($storage, $path);
- });
- $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) {
- $this->triggerPropagator($storage, $path);
- });
- $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) {
- $this->triggerPropagator($storage, $path);
- });
+ $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) {
+ $this->triggerPropagator($storage, $path);
+ });
+ $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) {
+ $this->triggerPropagator($storage, $path);
+ });
+ $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) {
+ $this->triggerPropagator($storage, $path);
+ });
- $propagator = $storage->getPropagator();
- $propagator->beginBatch();
- $scanner->backgroundScan();
- $propagator->commitBatch();
+ $propagator = $storage->getPropagator();
+ $propagator->beginBatch();
+ $scanner->backgroundScan();
+ $propagator->commitBatch();
+ } catch (\Exception $e) {
+ $this->logger->error("Error while trying to scan mount as {$mount->getMountPoint()}:" . $e->getMessage(), ['exception' => $e, 'app' => 'files']);
+ }
}
}