Skip to content

feat(archiver): name the archive after the resource - #661

Merged
dragonchaser merged 3 commits into
opencloud-eu:mainfrom
michaelstingl:issue-308-archive-filename
Jun 15, 2026
Merged

dragonchaser merged 3 commits into
opencloud-eu:mainfrom
michaelstingl:issue-308-archive-filename

Conversation

@michaelstingl

Copy link
Copy Markdown

Description

When an archive download targets a single resource, the handler resolves that resource's name, sanitizes it, and sets Content-Disposition with net.ContentDispositionAttachment, the same RFC 6266 filename* helper the single-file download uses, so the archive is named after the resource instead of the constant download.zip / download.tar. Multiple resources, or any failure to resolve the name, keep the download default.

The name is resolved in the handler, before the body is streamed: the Content-Disposition header is written before CreateZip / CreateTar build 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 /archiver handler, so one server-side change covers them, and the web client takes the filename from Content-Disposition, so no web change is needed.

How Has This Been Tested?

  • test environment: reva main (rebased onto current main), Go, local; plus the OpenCloud single binary with a go mod replace to this branch
  • gofmt, go vet, go test -race ./internal/http/services/archiver/..., and the pinned golangci-lint v2.10.1: all pass, 0 lint issues
  • unit: TestSanitizeArchiveName (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), and TestArchiveNameContentDisposition (a name with umlauts encodes to both the RFC 6266 filename* and the raw filename)
  • over HTTP (patched OpenCloud single binary): the Content-Disposition filename matches the folder for a personal-space folder (zip and tar), a multi-select download keeps download.zip, and a password-protected public link (a different principal) is named after the folder with the umlauts encoded per RFC 6266
  • not covered locally: the behat archiver suite runs only after a maintainer approves the fork CI run; the local proof is the unit tests plus the patched-binary header checks above

Screenshots (if appropriate):

n/a. Server-side Content-Disposition change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added (the behat suite has no archiver-filename scenario; this PR covers the logic at the unit level plus a patched-binary header check. A behat scenario can follow in the opencloud repo.)
  • Documentation added (n/a: reva generates the changelog from the PR title + Type:* label via ready-release-go, no fragment needed)

🤖 drafted with Claude Code, reviewed before submitting.

@rhafer rhafer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
michaelstingl force-pushed the issue-308-archive-filename branch from 5475573 to dd3b8dc Compare June 8, 2026 14:18
@michaelstingl

Copy link
Copy Markdown
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.

michaelstingl and others added 2 commits June 12, 2026 14:52
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
dragonchaser force-pushed the issue-308-archive-filename branch from dd3b8dc to 3f043a5 Compare June 12, 2026 13:03
Signed-off-by: Christian Richter <[email protected]>
@dragonchaser
dragonchaser requested review from aduffeck and butonic June 12, 2026 13:17

@dragonchaser dragonchaser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is approved, just removed the approval because I had overseen @rhafer 's comment: #661 (review)

@dragonchaser
dragonchaser merged commit 209c2cd into opencloud-eu:main Jun 15, 2026
19 checks passed
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Archiver should use appropriate filename for resulting archive

3 participants