mirror of
https://github.com/nextcloud/server.git
synced 2026-03-12 21:52:19 -04:00
fix(files): use isDownloadable for isSyncable
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
a2920dc7a9
commit
7b53dacfdd
2 changed files with 9 additions and 20 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.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<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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue