summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-02-15 17:04:37 +0100
committerGitHub <noreply@github.com>2023-02-15 17:04:37 +0100
commit63696fe2e30786e9a4c7cbfce84daf6278972b44 (patch)
tree5655571496364d736bff1e3fe85073e405eb8c3d /apps
parent54954cc374aed5265b53002b02fc40c9e93e7507 (diff)
parentd662092a5fe902cf2b35f9592052b5409f0fdaa7 (diff)
downloadnextcloud-server-63696fe2e30786e9a4c7cbfce84daf6278972b44.tar.gz
nextcloud-server-63696fe2e30786e9a4c7cbfce84daf6278972b44.zip
Merge pull request #36465 from nextcloud/bugfix/trashbin-concurrency
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/Trashbin.php24
-rw-r--r--apps/files_trashbin/src/filelist.js24
2 files changed, 12 insertions, 36 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index 46a2b07fc07..00e6b35cc62 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -69,13 +69,6 @@ class Trashbin {
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
*
@@ -980,23 +973,6 @@ class Trashbin {
/** @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
diff --git a/apps/files_trashbin/src/filelist.js b/apps/files_trashbin/src/filelist.js
index 8920dcbf8b9..e113b0f0ffa 100644
--- a/apps/files_trashbin/src/filelist.js
+++ b/apps/files_trashbin/src/filelist.js
@@ -25,6 +25,9 @@
*
*/
+// eslint-disable-next-line import/no-unresolved, node/no-missing-import
+import PQueue from 'p-queue'
+
/* eslint-disable */
(function() {
var DELETED_REGEXP = new RegExp(/^(.+)\.d[0-9]+$/)
@@ -61,6 +64,7 @@
var FileList = function($el, options) {
this.client = options.client
this.initialize($el, options)
+ this.deleteOperationQueue = new PQueue({ concurrency: 4 })
}
FileList.prototype = _.extend({}, OCA.Files.FileList.prototype,
/** @lends OCA.Trashbin.FileList.prototype */ {
@@ -185,12 +189,10 @@
this.fileMultiSelectMenu.toggleLoading('restore', true)
var restorePromises = files.map(function(file) {
- return self.client.move(OC.joinPaths('trash', self.getCurrentDirectory(), file), OC.joinPaths('restore', file), true)
- .then(
- function() {
- self._removeCallback([file])
- }
- )
+ return self.deleteOperationQueue.add(async () => {
+ self.client.move(OC.joinPaths('trash', self.getCurrentDirectory(), file), OC.joinPaths('restore', file), true)
+ self._removeCallback([file])
+ })
})
return Promise.all(restorePromises).then(
function() {
@@ -226,12 +228,10 @@
} else {
this.fileMultiSelectMenu.toggleLoading('delete', true)
var deletePromises = files.map(function(file) {
- return self.client.remove(OC.joinPaths('trash', self.getCurrentDirectory(), file))
- .then(
- function() {
- self._removeCallback([file])
- }
- )
+ return self.deleteOperationQueue.add(async () => {
+ await self.client.remove(OC.joinPaths('trash', self.getCurrentDirectory(), file))
+ self._removeCallback([file])
+ })
})
return Promise.all(deletePromises).then(
function() {