Skip to content

fix: Load preview URL for download-disabled shares - #2484

Closed
susnux wants to merge 1 commit into
masterfrom
fix/bring-back-no-download-shares
Closed

susnux wants to merge 1 commit into
masterfrom
fix/bring-back-no-download-shares

Conversation

@susnux

@susnux susnux commented Sep 8, 2024

Copy link
Copy Markdown
Contributor

This was possible on Nextcloud 30 and previous due to a "bug": The download permission was simply not rejected for public shares, just a hide flag was set on the public share.

Now the permissions are correctly set, so loading a preview is not possible. The work-around is to allow previews when the correct header is set.

@susnux susnux added bug Something isn't working 2. developing Work in progress labels Sep 8, 2024
@skjnldsv
skjnldsv force-pushed the fix/hide-download-correctly branch 2 times, most recently from 8f0dfcc to 4263b72 Compare September 15, 2024 09:27
@nextcloud-command
nextcloud-command force-pushed the fix/hide-download-correctly branch from 4263b72 to 86f71c2 Compare September 15, 2024 09:38
@skjnldsv
skjnldsv force-pushed the fix/hide-download-correctly branch from 86f71c2 to 8659a4c Compare September 15, 2024 09:58
Base automatically changed from fix/hide-download-correctly to master September 15, 2024 10:56
An error occurred while trying to automatically change base from fix/hide-download-correctly to master September 15, 2024 10:56
@susnux
susnux marked this pull request as ready for review October 28, 2024 18:44
@susnux
susnux force-pushed the fix/bring-back-no-download-shares branch from ad15a91 to ef4dc7d Compare October 29, 2024 09:27
@susnux susnux added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 29, 2024
This was possible on Nextcloud 30 and previous due to a "bug":
The `download` permission was simply not rejected for public shares,
just a `hide` flag was set on the public share.

Now the permissions are correctly set, so loading a preview is not possible.
The work-around is to allow previews when the correct header is set.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@skjnldsv
skjnldsv force-pushed the fix/bring-back-no-download-shares branch from ef4dc7d to 83a5ae1 Compare January 14, 2025 11:51
@skjnldsv

Copy link
Copy Markdown
Member

Still valid @susnux ?

@skjnldsv

Copy link
Copy Markdown
Member

Thanks for this, and sorry it sat so long. Both things it was chained on landed back in 2024 (#2482, and nextcloud/server#47831), and then nobody picked it back up.

Closing it here because this repository is frozen: the viewer now lives in nextcloud-libraries/nextcloud-viewer as @nextcloud/viewer, and master no longer takes changes. Only the stable branches are still updated until they go EOL.

Your fix is in the library as nextcloud-libraries/nextcloud-viewer#51, with a Co-authored-by for you. I wrote it fresh rather than cherry-picking, so it is worth saying what I changed and why:

  • getPreviewIfAny stays synchronous. Making it async pushes both Images.vue and Videos.vue out of a computed and into watcher-and-ref shapes, and the library already refetches by hand when the element fails to load (for E2EE files). That retry now picks what to fetch based on canDownload, so the change is a few lines and an unrestricted file still loads straight from the URL with no extra request.
  • Object URL rather than a FileReader data URL, so the image is not held as base64 in the DOM. Promise.withResolvers then isn't needed, and neither is the tsconfig bump.
  • The refactors in your PR (PreviewUrl.js, models.ts, numberUtil.ts, BasicFileInfo) don't apply: that layout was reworked during the extraction.

The x-nc-preview mechanism itself is exactly as you had it.

One thing your PR made me notice: the existing fallback never revoked the object URLs it created, so paging through a folder of E2EE files held all of them until the viewer closed. That is fixed alongside.

@skjnldsv skjnldsv closed this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants