Skip to content

Conversation

@skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Oct 28, 2025

Manual push of #55992 from community

Closes #55992

@skjnldsv skjnldsv self-assigned this Oct 28, 2025
@skjnldsv skjnldsv requested a review from a team as a code owner October 28, 2025 15:56
@skjnldsv skjnldsv added the 4. to release Ready to be released and/or waiting for tests to finish label Oct 28, 2025
@skjnldsv skjnldsv requested review from artonge, sorbaugh and szaimen and removed request for a team October 28, 2025 15:56
@skjnldsv
Copy link
Member Author

/compile

This patch ensures that the "Open locally" context menu item is not
displayed for files in a share where the "download and sync" permission
has not been granted.

This prevents user confusion, as the action would fail anyway. The fix
adds a permission check before rendering the menu item, and adds a
corresponding unit test to verify this behavior.

Resolves: #54970

Signed-off-by: Fauzan <[email protected]>
Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

}

return true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Signed-off-by: nextcloud-command <[email protected]>
Comment on lines +52 to +66
// check hide-download property of shares
if (node.attributes['hide-download'] === true
|| node.attributes['hide-download'] === 'true'
) {
return false
}

// If the mount type is a share, ensure it got download permissions.
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 !== undefined) {
return downloadAttribute.value === true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isnt this basically

Suggested change
// check hide-download property of shares
if (node.attributes['hide-download'] === true
|| node.attributes['hide-download'] === 'true'
) {
return false
}
// If the mount type is a share, ensure it got download permissions.
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 !== undefined) {
return downloadAttribute.value === true
}
}
if (!isDownloadable(node)) {
return false
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow me to jump into the discussion. Yes, it’s basically the same logic as the isDownloadable function. I just copied and pasted the logic. But doesn’t your suggestion make the node.permissions validation repetitive? It already checks the UPDATE permission, which means it automatically has READ permission.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already checks the UPDATE permission, which means it automatically has READ permission

you could have UPDATE without READ per se :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad:), should i update it first? re-commit to my fork?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants