Skip to content

Commit 0ad77fa

Browse files
authored
Merge pull request #45237 from nextcloud/45234-que-deletion-requests
2 parents f3e72af + 18f5507 commit 0ad77fa

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

apps/files/src/actions/deleteAction.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
import { emit } from '@nextcloud/event-bus'
2323
import { Permission, Node, View, FileAction, FileType } from '@nextcloud/files'
2424
import { showInfo } from '@nextcloud/dialogs'
25-
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
25+
import { translate as t } from '@nextcloud/l10n'
2626
import axios from '@nextcloud/axios'
2727

2828
import CloseSvg from '@mdi/svg/svg/close.svg?raw'
2929
import NetworkOffSvg from '@mdi/svg/svg/network-off.svg?raw'
3030
import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw'
3131

3232
import logger from '../logger.js'
33+
import PQueue from 'p-queue'
3334

3435
const canUnshareOnly = (nodes: Node[]) => {
3536
return nodes.every(node => node.attributes['is-mount-root'] === true
@@ -119,6 +120,8 @@ const displayName = (nodes: Node[], view: View) => {
119120
return t('files', 'Delete')
120121
}
121122

123+
const queue = new PQueue({ concurrency: 1 })
124+
122125
export const action = new FileAction({
123126
id: 'delete',
124127
displayName,
@@ -183,7 +186,19 @@ export const action = new FileAction({
183186
return Promise.all(nodes.map(() => false))
184187
}
185188

186-
return Promise.all(nodes.map(node => this.exec(node, view, dir)))
189+
// Map each node to a promise that resolves with the result of exec(node)
190+
const promises = nodes.map(node => {
191+
// Create a promise that resolves with the result of exec(node)
192+
const promise = new Promise<boolean>(resolve => {
193+
queue.add(async () => {
194+
const result = await this.exec(node, view, dir)
195+
resolve(result !== null ? result : false)
196+
})
197+
})
198+
return promise
199+
})
200+
201+
return Promise.all(promises)
187202
},
188203

189204
order: 100,

dist/files-init.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)