mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Merge pull request #45376 from nextcloud/backport/45237/stable27
[stable27] perf(deleteAction): Queue delete requests
This commit is contained in:
commit
7e400afcbb
3 changed files with 21 additions and 5 deletions
|
|
@ -28,7 +28,11 @@ import TrashCan from '@mdi/svg/svg/trash-can.svg?raw'
|
|||
import { registerFileAction, FileAction } from '../services/FileAction.ts'
|
||||
import logger from '../logger.js'
|
||||
import type { Navigation } from '../services/Navigation.ts'
|
||||
import { encodePath } from '@nextcloud/paths';
|
||||
import { encodePath } from '@nextcloud/paths'
|
||||
|
||||
import PQueue from 'p-queue'
|
||||
|
||||
const queue = new PQueue({ concurrency: 1 })
|
||||
|
||||
registerFileAction(new FileAction({
|
||||
id: 'delete',
|
||||
|
|
@ -63,7 +67,19 @@ registerFileAction(new FileAction({
|
|||
}
|
||||
},
|
||||
async execBatch(nodes: Node[], view: Navigation, 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-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue