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

[stable25] Avoid locking on restore/delete and limit concurrent requests #36745

Merged
merged 1 commit into from
Feb 27, 2023
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
24 changes: 0 additions & 24 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ class Trashbin {
// unit: percentage; 50% of available disk space/quota
public const DEFAULTMAXSIZE = 50;

/**
* Whether versions have already be rescanned during this PHP request
*
* @var bool
*/
private static $scannedVersions = false;

/**
* Ensure we don't need to scan the file during the move to trash
* by triggering the scan in the pre-hook
Expand Down Expand Up @@ -980,23 +973,6 @@ private static function getVersionsFromTrash($filename, $timestamp, $user) {
/** @var \OC\Files\Storage\Storage $storage */
[$storage,] = $view->resolvePath('/');

//force rescan of versions, local storage may not have updated the cache
$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));
if ($timestamp) {
// fetch for old versions
Expand Down