Skip to content

Commit

Permalink
fix(files_sharing): Handle download permission the same way for publi…
Browse files Browse the repository at this point in the history
…c and internal shares

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Sep 3, 2024
1 parent b775d47 commit d431af5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ const isDownloadable = function(node: Node) {
}

// If the mount type is a share, ensure it got download permissions.
if (node.attributes['mount-type'] === 'shared') {
const shareAttributes = JSON.parse(node.attributes['share-attributes'] ?? '[]') as Array<ShareAttribute>
const downloadAttribute = shareAttributes?.find?.((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
if (downloadAttribute !== undefined && downloadAttribute.value === false) {
return false
if (node.attributes['share-attributes']) {
const shareAttributes = JSON.parse(node.attributes['share-attributes'] || '[]') as Array<ShareAttribute>
const downloadAttribute = shareAttributes.find(({ scope, key }: ShareAttribute) => scope === 'permissions' && key === 'download')
if (downloadAttribute) {
return downloadAttribute.value === true
}
}

Expand Down
3 changes: 3 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1221,10 +1221,13 @@ public function updateShare(
}

// Update hide download state
$attributes = $share->getAttributes() ?? $share->newAttributes();
if ($hideDownload === 'true') {
$share->setHideDownload(true);
$attributes->setAttribute('permissions', 'download', false);
} elseif ($hideDownload === 'false') {
$share->setHideDownload(false);
$attributes->setAttribute('permissions', 'download', true);
}

$newPermissions = null;
Expand Down
2 changes: 1 addition & 1 deletion build/integration/dav_features/dav-v2-public.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
Feature: dav-v2-public
Background:
Expand Down

0 comments on commit d431af5

Please sign in to comment.