From 7b53dacfdd27963241a4eec402e1dcc75f283f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Fri, 28 Nov 2025 08:57:38 +0100 Subject: [PATCH] fix(files): use `isDownloadable` for `isSyncable` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ [skip ci] --- apps/files/src/actions/openLocallyAction.ts | 3 ++- apps/files/src/utils/permissions.ts | 26 ++++++--------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/apps/files/src/actions/openLocallyAction.ts b/apps/files/src/actions/openLocallyAction.ts index 3d6c00f1d59..1d81da16d0e 100644 --- a/apps/files/src/actions/openLocallyAction.ts +++ b/apps/files/src/actions/openLocallyAction.ts @@ -5,13 +5,14 @@ import { encodePath } from '@nextcloud/paths' import { generateOcsUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' -import { FileAction, Permission, type Node } from '@nextcloud/files' +import { FileAction, type Node } from '@nextcloud/files' import { showError, DialogBuilder } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw' import IconWeb from '@mdi/svg/svg/web.svg?raw' import { isPublicShare } from '@nextcloud/sharing/public' +import { isSyncable } from '../utils/permissions.ts' export const action = new FileAction({ id: 'edit-locally', diff --git a/apps/files/src/utils/permissions.ts b/apps/files/src/utils/permissions.ts index a13f6a13ab5..a0cdd2d24ec 100644 --- a/apps/files/src/utils/permissions.ts +++ b/apps/files/src/utils/permissions.ts @@ -36,7 +36,6 @@ export function isDownloadable(node: Node): boolean { return true } - /** * Check permissions on the node if it can be synced/open locally * @@ -44,25 +43,14 @@ export function isDownloadable(node: Node): boolean { * @return True if syncable, false otherwise */ export function isSyncable(node: Node): boolean { + if (!node.isDavResource) { + return false + } + if ((node.permissions & Permission.UPDATE) === 0) { return false } - // check hide-download property of shares - if (node.attributes['hide-download'] === true - || node.attributes['hide-download'] === 'true' - ) { - return false - } - - // If the mount type is a share, ensure it got download permissions. - if (node.attributes['share-attributes']) { - const shareAttributes = JSON.parse(node.attributes['share-attributes'] || '[]') as Array - const downloadAttribute = shareAttributes.find(({ scope, key }: ShareAttribute) => scope === 'permissions' && key === 'download') - if (downloadAttribute !== undefined) { - return downloadAttribute.value === true - } - } - - return true -} \ No newline at end of file + // Syncable has the same permissions as downloadable for now + return isDownloadable(node) +}