Skip to content

Commit

Permalink
Merge branch 'master' of github.com:byt3sage/server into bug/oauth-in…
Browse files Browse the repository at this point in the history
…stance-name-decoding-39956
  • Loading branch information
byt3sage committed Dec 13, 2024
2 parents cfafc3c + 30ff2ae commit 4c57f0b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
23 changes: 22 additions & 1 deletion apps/files/src/actions/favoriteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ 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'
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)
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions apps/files/src/services/ServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { generateUrl } from '@nextcloud/router'
import { generateUrl, getRootUrl } from '@nextcloud/router'
import logger from '../logger.ts'

export default () => {
Expand All @@ -11,7 +11,8 @@ export default () => {
window.addEventListener('load', async () => {
try {
const url = generateUrl('/apps/files/preview-service-worker.js', {}, { noRewrite: true })
const registration = await navigator.serviceWorker.register(url, { scope: '/' })
const scope = getRootUrl()
const registration = await navigator.serviceWorker.register(url, { scope })
logger.debug('SW registered: ', { registration })
} catch (error) {
logger.error('SW registration failed: ', { error })
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ public function writeStream(string $path, $stream, ?int $size = null): int {
$stats = fstat($stream);
if (is_array($stats) && isset($stats['size'])) {
$size = $stats['size'];
$this->logger->warning("stream size $size");
}
}

Expand Down

0 comments on commit 4c57f0b

Please sign in to comment.