diff options
author | Robin Appelman <robin@icewind.nl> | 2025-04-25 18:35:12 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2025-04-25 18:40:03 +0200 |
commit | bb4cf2830aca984c001542b3cdc2ebc78bba6941 (patch) | |
tree | ae68a2574ea38a2b833be627df600c1f14096681 /lib/private/Files/Utils | |
parent | 5f40fad790a16f9613e796728c23f47e80bcb6ee (diff) | |
download | nextcloud-server-scan-locked-error.tar.gz nextcloud-server-scan-locked-error.zip |
fix: better error message when trying to scan a folder that is already being scannedscan-locked-error
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Utils')
-rw-r--r-- | lib/private/Files/Utils/Scanner.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 4d94629443f..e9ed351b27b 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -29,6 +29,7 @@ use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\IDBConnection; use OCP\Lock\ILockingProvider; +use OCP\Lock\LockedException; use Psr\Log\LoggerInterface; /** @@ -260,7 +261,15 @@ class Scanner extends PublicEmitter { try { $propagator = $storage->getPropagator(); $propagator->beginBatch(); - $scanner->scan($relativePath, $recursive, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); + try { + $scanner->scan($relativePath, $recursive, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); + } catch (LockedException $e) { + if (is_string($e->getReadablePath()) && str_starts_with($e->getReadablePath(), 'scanner::')) { + throw new LockedException("scanner::$dir", $e, $e->getExistingLock()); + } else { + throw $e; + } + } $cache = $storage->getCache(); if ($cache instanceof Cache) { // only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner |