fix(files): use `isDownloadable` for `isSyncable`

Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>

[skip ci]
pull/56737/head
John Molakvoæ 2025-11-28 08:57:38 +07:00 committed by skjnldsv
parent 4b1477dd1b
commit 9da57f6712
2 changed files with 7 additions and 18 deletions

@ -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',

@ -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.permissions & Permission.UPDATE) === 0) {
if (!node.isDavResource) {
return false
}
// check hide-download property of shares
if (node.attributes['hide-download'] === true
|| node.attributes['hide-download'] === 'true'
) {
if ((node.permissions & Permission.UPDATE) === 0) {
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<ShareAttribute>
const downloadAttribute = shareAttributes.find(({ scope, key }: ShareAttribute) => scope === 'permissions' && key === 'download')
if (downloadAttribute !== undefined) {
return downloadAttribute.value === true
}
}
return true
}
// Syncable has the same permissions as downloadable for now
return isDownloadable(node)
}