Skip to content

Commit 9072b59

Browse files
artongeAndyScherzinger
authored andcommitted
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>
1 parent f56866c commit 9072b59

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

apps/files/src/actions/downloadAction.ts

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

44-
// If the mount type is a share, ensure it got download permissions.
4544
const isDownloadable = function(node: Node) {
46-
if (node.attributes['mount-type'] !== 'shared') {
47-
return true
45+
if ((node.permissions & Permission.READ) === 0) {
46+
return false
4847
}
4948

50-
const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find(attribute => attribute.scope === 'permissions' && attribute.key === 'download')
51-
52-
if (downloadAttribute === undefined) {
53-
return true
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+
}
5455
}
5556

56-
return downloadAttribute.enable
57+
return true
5758
}
5859

5960
export const action = new FileAction({
@@ -74,8 +75,7 @@ export const action = new FileAction({
7475
return false
7576
}
7677

77-
return nodes
78-
.every(node => ((node.permissions & Permission.READ) !== 0) && isDownloadable(node))
78+
return nodes.every(isDownloadable)
7979
},
8080

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

0 commit comments

Comments
 (0)