]> source.dussan.org Git - nextcloud-server.git/commitdiff
Ensure share has download permissions in F2V
authorLouis <louis@chmn.me>
Thu, 23 Nov 2023 11:29:17 +0000 (12:29 +0100)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Fri, 24 Nov 2023 17:59:38 +0000 (17:59 +0000)
Signed-off-by: Louis <louis@chmn.me>
apps/files/src/actions/downloadAction.ts

index 0b1c88fa985efab01ab4cfd1a7fbd3bd50c251c5..c7b07d7af8004f1fd00f182da445c81959f51019 100644 (file)
@@ -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) {