Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable22] Don't die with LockedException when removing/restoring multiple files from trash #30391

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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