diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-02-01 08:17:26 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2023-02-02 17:23:05 +0100 |
commit | d92538850f9d031d7e1d80479e259050f86d73ae (patch) | |
tree | ece2c58d0b3c1b4470b87a3a37445fc470f83695 /apps | |
parent | 6f3c4f2255ed73601fa5eac3048d679caa3065e0 (diff) | |
download | nextcloud-server-d92538850f9d031d7e1d80479e259050f86d73ae.tar.gz nextcloud-server-d92538850f9d031d7e1d80479e259050f86d73ae.zip |
fix: Limit trashbin restore/delete to 2 concurrent request to avoid locking in the backend
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_trashbin/src/filelist.js | 24 |
1 files changed, 12 insertions, 12 deletions
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() { |