diff options
author | Sven Strickroth <email@cs-ware.de> | 2021-08-15 18:58:16 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-12-23 10:26:57 +0000 |
commit | 708d98d0788c632cb8d1772aa915567e1115e7fb (patch) | |
tree | 317bfdb9347de54701c534f03c74b06d40dd7519 /apps/files_trashbin | |
parent | ad8cf1a2b41cde9f9cad8e7994db1d785053ceba (diff) | |
download | nextcloud-server-708d98d0788c632cb8d1772aa915567e1115e7fb.tar.gz nextcloud-server-708d98d0788c632cb8d1772aa915567e1115e7fb.zip |
Don't die with LockedException when removing/restoring multiple files from trash
fixes issue #16491
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 0e16c56ed8d..6aec2f9821e 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -968,9 +968,20 @@ class Trashbin { [$storage,] = $view->resolvePath('/'); //force rescan of versions, local storage may not have updated the cache - if (!self::$scannedVersions) { - $storage->getScanner()->scan('files_trashbin/versions'); - self::$scannedVersions = true; + $waitstart = time(); + while (!self::$scannedVersions) { + try { + $storage->getScanner()->scan('files_trashbin/versions'); + self::$scannedVersions = true; + } catch (LockedException $e) { + /* a concurrent remove/restore from trash occurred, + * retry with a maximum wait time of approx. 15 seconds + */ + if (time() - $waitstart > 15) { + throw $e; + } + usleep(50000 + rand(0, 10000)); + } } $pattern = \OC::$server->getDatabaseConnection()->escapeLikeParameter(basename($filename)); |