mirror of
https://github.com/nextcloud/server.git
synced 2026-05-22 01:55:56 -04:00
Merge pull request #45237 from nextcloud/45234-que-deletion-requests
This commit is contained in:
commit
0ad77fa937
3 changed files with 21 additions and 6 deletions
|
|
@ -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,
|
||||
|
|
|
|||
6
dist/files-init.js
vendored
6
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