Skip to content

Commit

Permalink
Don't die with LockedException when removing/restoring multiple files…
Browse files Browse the repository at this point in the history
… from trash

fixes issue #16491

Signed-off-by: Sven Strickroth <email@cs-ware.de>
  • Loading branch information
csware authored and backportbot[bot] committed Dec 23, 2021
1 parent a70dabf commit d90bf1a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,20 @@ private static function getVersionsFromTrash($filename, $timestamp, $user) {
[$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));
Expand Down

0 comments on commit d90bf1a

Please sign in to comment.