Skip to content

Commit

Permalink
Merge pull request #41685 from nextcloud/artonge/fix/download_permiss…
Browse files Browse the repository at this point in the history
…ions

Ensure share has download permissions in F2V
  • Loading branch information
AndyScherzinger authored Nov 24, 2023
2 parents 0b75fe1 + 78e75bf commit 3b9c240
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
20 changes: 17 additions & 3 deletions apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ const downloadNodes = function(dir: string, nodes: Node[]) {
triggerDownload(url)
}

const isDownloadable = function(node: Node) {
if ((node.permissions & Permission.READ) === 0) {
return false
}

// 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 true
}

export const action = new FileAction({
id: 'download',
displayName: () => t('files', 'Download'),
Expand All @@ -59,9 +75,7 @@ export const action = new FileAction({
return false
}

return nodes
.map(node => node.permissions)
.every(permission => (permission & Permission.READ) !== 0)
return nodes.every(isDownloadable)
},

async exec(node: Node, view: View, dir: string) {
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

0 comments on commit 3b9c240

Please sign in to comment.