Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] Ensure share has download permissions in F2V #41742

Merged
merged 2 commits into from Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions apps/files/src/actions/downloadAction.ts
Expand Up @@ -41,6 +41,22 @@
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

Check warning on line 53 in apps/files/src/actions/downloadAction.ts

View check run for this annotation

Codecov / codecov/patch

apps/files/src/actions/downloadAction.ts#L53

Added line #L53 was not covered by tests
}
}

return true
}

export const action = new FileAction({
id: 'download',
displayName: () => t('files', 'Download'),
Expand All @@ -59,9 +75,7 @@
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.