Merge pull request #41742 from nextcloud/backport/41685/stable28

[stable28] Ensure share has download permissions in F2V
This commit is contained in:
Andy Scherzinger 2023-11-24 21:15:32 +01:00 committed by GitHub
commit 919b448bb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 6 deletions

View file

@ -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'),
@ -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) {

4
dist/files-init.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long