mirror of
https://github.com/nextcloud/server.git
synced 2026-06-06 15:23:17 -04:00
Merge pull request #45327 from nextcloud/backport/45237/stable28
[stable28] perf(deleteAction): Queue delete requests
This commit is contained in:
commit
58711fbf3c
3 changed files with 19 additions and 4 deletions
|
|
@ -29,6 +29,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
|
||||
|
|
@ -58,6 +59,8 @@ const isAllFolders = (nodes: Node[]) => {
|
|||
return !nodes.some(node => node.type !== FileType.Folder)
|
||||
}
|
||||
|
||||
const queue = new PQueue({ concurrency: 1 })
|
||||
|
||||
export const action = new FileAction({
|
||||
id: 'delete',
|
||||
displayName(nodes: Node[], view: View) {
|
||||
|
|
@ -152,7 +155,19 @@ export const action = new FileAction({
|
|||
}
|
||||
},
|
||||
async execBatch(nodes: Node[], view: View, dir: string) {
|
||||
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,
|
||||
|
|
|
|||
4
dist/files-init.js
vendored
4
dist/files-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-init.js.map
vendored
2
dist/files-init.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue