From f56866cc8208f36b4a0e2ee35d8e278c1b7db067 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 23 Nov 2023 12:29:17 +0100 Subject: [PATCH] Ensure share has download permissions in F2V Signed-off-by: Louis --- apps/files/src/actions/downloadAction.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/files/src/actions/downloadAction.ts b/apps/files/src/actions/downloadAction.ts index 0b1c88fa985..c7b07d7af80 100644 --- a/apps/files/src/actions/downloadAction.ts +++ b/apps/files/src/actions/downloadAction.ts @@ -41,6 +41,21 @@ const downloadNodes = function(dir: string, nodes: Node[]) { triggerDownload(url) } +// If the mount type is a share, ensure it got download permissions. +const isDownloadable = function(node: Node) { + if (node.attributes['mount-type'] !== 'shared') { + return true + } + + const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find(attribute => attribute.scope === 'permissions' && attribute.key === 'download') + + if (downloadAttribute === undefined) { + return true + } + + return downloadAttribute.enable +} + export const action = new FileAction({ id: 'download', displayName: () => t('files', 'Download'), @@ -60,8 +75,7 @@ export const action = new FileAction({ } return nodes - .map(node => node.permissions) - .every(permission => (permission & Permission.READ) !== 0) + .every(node => ((node.permissions & Permission.READ) !== 0) && isDownloadable(node)) }, async exec(node: Node, view: View, dir: string) { -- 2.39.5