diff options
author | Louis <louis@chmn.me> | 2023-11-23 12:40:03 +0100 |
---|---|---|
committer | nextcloud-command <nextcloud-command@users.noreply.github.com> | 2023-11-24 18:12:35 +0000 |
commit | 15e4c780145dfc65c17708d3a4216c5bde849bd3 (patch) | |
tree | 1d79d6d7bc8f0a6d5588237c83c0a76dcb1b667e /apps/files/src/actions | |
parent | 5e8ee6e0d66d9ec3c389974d6ddf3728885db2ce (diff) | |
download | nextcloud-server-15e4c780145dfc65c17708d3a4216c5bde849bd3.tar.gz nextcloud-server-15e4c780145dfc65c17708d3a4216c5bde849bd3.zip |
Ensure share has download permissions in F2V
Signed-off-by: Louis <louis@chmn.me>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/files/src/actions')
-rw-r--r-- | apps/files/src/actions/downloadAction.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/files/src/actions/downloadAction.ts b/apps/files/src/actions/downloadAction.ts index c7b07d7af80..0d8bfb7dfc2 100644 --- a/apps/files/src/actions/downloadAction.ts +++ b/apps/files/src/actions/downloadAction.ts @@ -41,19 +41,20 @@ 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 + if ((node.permissions & Permission.READ) === 0) { + return false } - const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find(attribute => attribute.scope === 'permissions' && attribute.key === 'download') - - if (downloadAttribute === undefined) { - return true + // If the mount type is a share, ensure it got download permissions. + if (node.attributes['mount-type'] === 'shared') { + const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download') + if (downloadAttribute !== undefined && downloadAttribute.enabled === false) { + return false + } } - return downloadAttribute.enable + return true } export const action = new FileAction({ @@ -74,8 +75,7 @@ export const action = new FileAction({ return false } - return nodes - .every(node => ((node.permissions & Permission.READ) !== 0) && isDownloadable(node)) + return nodes.every(isDownloadable) }, async exec(node: Node, view: View, dir: string) { |