Skip to content

Commit 3b9c240

Browse files
Merge pull request #41685 from nextcloud/artonge/fix/download_permissions
Ensure share has download permissions in F2V
2 parents 0b75fe1 + 78e75bf commit 3b9c240

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

apps/files/src/actions/downloadAction.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ const downloadNodes = function(dir: string, nodes: Node[]) {
4141
triggerDownload(url)
4242
}
4343

44+
const isDownloadable = function(node: Node) {
45+
if ((node.permissions & Permission.READ) === 0) {
46+
return false
47+
}
48+
49+
// If the mount type is a share, ensure it got download permissions.
50+
if (node.attributes['mount-type'] === 'shared') {
51+
const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
52+
if (downloadAttribute !== undefined && downloadAttribute.enabled === false) {
53+
return false
54+
}
55+
}
56+
57+
return true
58+
}
59+
4460
export const action = new FileAction({
4561
id: 'download',
4662
displayName: () => t('files', 'Download'),
@@ -59,9 +75,7 @@ export const action = new FileAction({
5975
return false
6076
}
6177

62-
return nodes
63-
.map(node => node.permissions)
64-
.every(permission => (permission & Permission.READ) !== 0)
78+
return nodes.every(isDownloadable)
6579
},
6680

6781
async exec(node: Node, view: View, dir: string) {

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)