Repository navigation
feat(archiver): name the archive after the resource - #661
Merged
dragonchaser merged 3 commits intoJun 15, 2026
Merged
Conversation
rhafer
reviewed
Jun 8, 2026
Member
There was a problem hiding this comment.
Looks good to me. As we're currently in a bugfixes-only mode, I'd prefer to merge this after the coming stable release though.
@michaelstingl Would you mind doing a force push once more, so that I can approve the CI run? For some reason the job created for this originaily is no longer available in woodpecker.
michaelstingl
force-pushed
the
issue-308-archive-filename
branch
from
June 8, 2026 14:18
5475573 to
dd3b8dc
Compare
Author
|
Force-pushed: rebased onto current main, archiver unit tests green locally. A fresh CI run is available to approve. No rush on the merge, waiting for the stable release is fine. 🤖 drafted with Claude Code, reviewed before submitting. |
A single-resource archive download was always named "download.zip" (or "download.tar"), regardless of the folder it contained. When the request targets exactly one resource, resolve that resource's name and use it for the Content-Disposition filename; keep "download" for multi-resource downloads and whenever the name cannot be resolved. The name is resolved in the handler, before the response body is streamed. The archive walker only learns the root name while streaming, which is too late to set the header, so a single Stat up front provides it. The header is built with the existing net.ContentDispositionAttachment helper, giving the RFC 6266 filename* form already used by the single-file download; the archiver was the one download path that did not name after the resource. The name is sanitized before it reaches the header: control characters, quotes, and path separators are removed. Fixes: opencloud-eu#308
Signed-off-by: Christian Richter <[email protected]>
dragonchaser
force-pushed
the
issue-308-archive-filename
branch
from
June 12, 2026 13:03
dd3b8dc to
3f043a5
Compare
Signed-off-by: Christian Richter <[email protected]>
dragonchaser
approved these changes
Jun 12, 2026
dragonchaser
requested changes
Jun 12, 2026
dragonchaser
left a comment
Member
There was a problem hiding this comment.
is approved, just removed the approval because I had overseen @rhafer 's comment: #661 (review)
dragonchaser
approved these changes
Jun 15, 2026
7 tasks
v-scharf
added a commit
to opencloud-eu/web
that referenced
this pull request
Jun 16, 2026
v-scharf
added a commit
to opencloud-eu/web
that referenced
this pull request
Jun 16, 2026
v-scharf
added a commit
to opencloud-eu/web
that referenced
this pull request
Jun 16, 2026
v-scharf
added a commit
to opencloud-eu/web
that referenced
this pull request
Jun 16, 2026
* e2e-test: archive uses folder name related opencloud-eu/reva#661 * Change resource from testavatar.jpg to testavatar.png * Add OC_EVENTS_ENDPOINT to configuration
michaelstingl
added a commit
to michaelstingl/opencloud-eu-opencloud
that referenced
this pull request
Jul 7, 2026
…ource An archive download of a single folder was always named "download.zip" until the handler resolved the resource name for the Content-Disposition header (opencloud-eu/reva#661). Add a scenario asserting the archive of a folder carries a Content-Disposition filename of the folder, reusing the archiver download step and the header-regex assertion. Verified red->green on posix and decomposed: red on an opencloud built on a reva with the change reverted (the archive is "download.zip"), green on the shipped reva.
2 of 9 tasks
v-scharf
pushed a commit
to michaelstingl/opencloud-eu-opencloud
that referenced
this pull request
Jul 17, 2026
…ource An archive download of a single folder was always named "download.zip" until the handler resolved the resource name for the Content-Disposition header (opencloud-eu/reva#661). Add a scenario asserting the archive of a folder carries a Content-Disposition filename of the folder, reusing the archiver download step and the header-regex assertion. Verified red->green on posix and decomposed: red on an opencloud built on a reva with the change reverted (the archive is "download.zip"), green on the shipped reva.
v-scharf
pushed a commit
to opencloud-eu/opencloud
that referenced
this pull request
Jul 17, 2026
…ource (#3080) An archive download of a single folder was always named "download.zip" until the handler resolved the resource name for the Content-Disposition header (opencloud-eu/reva#661). Add a scenario asserting the archive of a folder carries a Content-Disposition filename of the folder, reusing the archiver download step and the header-regex assertion. Verified red->green on posix and decomposed: red on an opencloud built on a reva with the change reverted (the archive is "download.zip"), green on the shipped reva.
3 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When an archive download targets a single resource, the handler resolves that resource's name, sanitizes it, and sets
Content-Dispositionwithnet.ContentDispositionAttachment, the same RFC 6266filename*helper the single-file download uses, so the archive is named after the resource instead of the constantdownload.zip/download.tar. Multiple resources, or any failure to resolve the name, keep thedownloaddefault.The name is resolved in the handler, before the body is streamed: the
Content-Dispositionheader is written beforeCreateZip/CreateTarbuild the archive, while the walker only resolves the root name during streaming, too late for the header. It is sanitized first (control characters, quotes and path separators removed), so a folder name cannot break the header or act as a path.Related Issue
Motivation and Context
All access contexts (personal space, project space, user share, public link) reach the same
/archiverhandler, so one server-side change covers them, and the web client takes the filename fromContent-Disposition, so no web change is needed.How Has This Been Tested?
main(rebased onto current main), Go, local; plus the OpenCloud single binary with ago mod replaceto this branchgofmt,go vet,go test -race ./internal/http/services/archiver/..., and the pinnedgolangci-lintv2.10.1: all pass, 0 lint issuesTestSanitizeArchiveName(quotes, slashes, CR/LF, C0/DEL/C1 controls, dot/dotdot, umlauts kept),TestResourceName(name, path-base fallback, sanitize, sanitize-to-empty, stat error, non-OK status and selector error all fall back to the default), andTestArchiveNameContentDisposition(a name with umlauts encodes to both the RFC 6266filename*and the rawfilename)Content-Dispositionfilename matches the folder for a personal-space folder (zip and tar), a multi-select download keepsdownload.zip, and a password-protected public link (a different principal) is named after the folder with the umlauts encoded per RFC 6266Screenshots (if appropriate):
n/a. Server-side
Content-Dispositionchange.Types of changes
Checklist:
Type:*label via ready-release-go, no fragment needed)🤖 drafted with Claude Code, reviewed before submitting.