fix(mirror): preserve content type during mirror sync#61
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes rc mirror so mirrored objects preserve the source object’s Content-Type, addressing a user-visible metadata loss during sync operations.
Changes:
- Add a mirror copy helper that attempts
head_objectto capturecontent_typeand forwards it into the destinationput_object. - Introduce small source/target traits to enable unit testing of the metadata-preserving copy behavior.
- Add an integration test that verifies
Content-Typeis preserved end-to-end (cp --content-type→mirror→stat --json).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/cli/src/commands/mirror.rs | Adds metadata-aware copy path (preserve content_type) plus unit tests around the helper. |
| crates/cli/tests/integration.rs | Adds an integration regression test verifying mirrored objects keep content_type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Related Issue
Closes #59.
Background
rc mirrorcopies objects between S3-compatible backends. Before this change, the mirror flow downloaded the source object bytes and uploaded them to the destination without forwarding the sourceContent-Type.That meant a source object such as
image/jpegcould be mirrored asapplication/octet-streamon the destination side. This is user-visible because browsers and downstream consumers may handle the mirrored object differently after the sync.Root Cause
The mirror implementation used
get_objectfollowed byput_object(..., None). Even thoughhead_objectalready exposed the source object'scontent_typethroughObjectInfo, the mirror upload path did not pass that metadata into the destination upload.Solution
This PR makes two related changes:
source_info.content_typeinto the destinationput_objectcall.AGENTS.mdto require semantic/conventional PR titles and clear PR descriptions that include issue, background, solution, and test status.This keeps the bug fix targeted to the reported mirror behavior while also documenting the PR rules used for this contribution.
Tests
The mirror fix was validated with the following checks on commit
44efbe6:cargo fmt --allcargo clippy --workspace -- -D warningscargo test --workspacecargo test -p rustfs-cli --features integration test_mirror_preserves_content_typeRegression coverage added in this PR includes:
image/jpegcontent type during mirror copiesNonecontent-type fallback pathimage/jpeg, mirrors it to another bucket, and verifies the destination still reportsimage/jpegviastat --jsonThe follow-up
AGENTS.mdupdate is a markdown-only documentation change in commit1326278, so no additional Rust checks were required under the repository rules.Notes
This PR fixes
Content-Typepreservation specifically. It does not attempt to mirror other object metadata beyond what the current upload interface supports.