diff options
author | Louis <louis@chmn.me> | 2024-05-16 19:52:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 19:52:23 +0200 |
commit | 7eb718c4417a93c691f6cf1f3e44e47035c545eb (patch) | |
tree | 11d62f65cec48c5564086c3787e3fc121114746d /apps/files | |
parent | 1463b889ec3f999c3380171c496a1052d4806dda (diff) | |
parent | 96b2827eb3635104629701d9229a10b6e8d32c86 (diff) | |
download | nextcloud-server-29.0.1rc1.tar.gz nextcloud-server-29.0.1rc1.zip |
Merge pull request #45328 from nextcloud/backport/45237/stable29v29.0.1rc1
[stable29] perf(deleteAction): Queue delete requests
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/src/actions/deleteAction.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts index c46de9c652e..458cfd05eef 100644 --- a/apps/files/src/actions/deleteAction.ts +++ b/apps/files/src/actions/deleteAction.ts @@ -22,7 +22,7 @@ import { emit } from '@nextcloud/event-bus' import { Permission, Node, View, FileAction, FileType } from '@nextcloud/files' import { showInfo } from '@nextcloud/dialogs' -import { translate as t, translatePlural as n } from '@nextcloud/l10n' +import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import CloseSvg from '@mdi/svg/svg/close.svg?raw' @@ -30,6 +30,7 @@ import NetworkOffSvg from '@mdi/svg/svg/network-off.svg?raw' import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw' import logger from '../logger.js' +import PQueue from 'p-queue' const canUnshareOnly = (nodes: Node[]) => { return nodes.every(node => node.attributes['is-mount-root'] === true @@ -119,6 +120,8 @@ const displayName = (nodes: Node[], view: View) => { return t('files', 'Delete') } +const queue = new PQueue({ concurrency: 1 }) + export const action = new FileAction({ id: 'delete', displayName, @@ -183,7 +186,19 @@ export const action = new FileAction({ return Promise.all(nodes.map(() => false)) } - return Promise.all(nodes.map(node => this.exec(node, view, dir))) + // Map each node to a promise that resolves with the result of exec(node) + const promises = nodes.map(node => { + // Create a promise that resolves with the result of exec(node) + const promise = new Promise<boolean>(resolve => { + queue.add(async () => { + const result = await this.exec(node, view, dir) + resolve(result !== null ? result : false) + }) + }) + return promise + }) + + return Promise.all(promises) }, order: 100, |