aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-12-11 20:08:26 +0100
committerGitHub <noreply@github.com>2024-12-11 20:08:26 +0100
commit30ff2ae5cc236542e817f64eb1534b7b87595d98 (patch)
treea26b08065e01df18b8a9be5c36c24f2841ff2374 /apps
parent1f6c8c17022d4faccfe5bbd7e6d1e11f7137851a (diff)
parentcb4b4d659e145dc2fd3ab4fda9f0f584c00aec2e (diff)
downloadnextcloud-server-30ff2ae5cc236542e817f64eb1534b7b87595d98.tar.gz
nextcloud-server-30ff2ae5cc236542e817f64eb1534b7b87595d98.zip
Merge pull request #49803 from nextcloud/backport/49432/master
Diffstat (limited to 'apps')
-rw-r--r--apps/files/src/actions/favoriteAction.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/apps/files/src/actions/favoriteAction.ts b/apps/files/src/actions/favoriteAction.ts
index 52beb6e7454..1c1057a553e 100644
--- a/apps/files/src/actions/favoriteAction.ts
+++ b/apps/files/src/actions/favoriteAction.ts
@@ -11,6 +11,7 @@ import { encodePath } from '@nextcloud/paths'
import { generateUrl } from '@nextcloud/router'
import { isPublicShare } from '@nextcloud/sharing/public'
import axios from '@nextcloud/axios'
+import PQueue from 'p-queue'
import Vue from 'vue'
import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw'
@@ -18,6 +19,8 @@ import StarSvg from '@mdi/svg/svg/star.svg?raw'
import logger from '../logger.ts'
+const queue = new PQueue({ concurrency: 5 })
+
// If any of the nodes is not favorited, we display the favorite action.
const shouldFavorite = (nodes: Node[]): boolean => {
return nodes.some(node => node.attributes.favorite !== 1)
@@ -89,7 +92,25 @@ export const action = new FileAction({
},
async execBatch(nodes: Node[], view: View) {
const willFavorite = shouldFavorite(nodes)
- return Promise.all(nodes.map(async node => await favoriteNode(node, view, willFavorite)))
+
+ // 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 () => {
+ try {
+ await favoriteNode(node, view, willFavorite)
+ resolve(true)
+ } catch (error) {
+ logger.error('Error while adding file to favorite', { error, source: node.source, node })
+ resolve(false)
+ }
+ })
+ })
+ return promise
+ })
+
+ return Promise.all(promises)
},
order: -50,