[Buckets] Support rsync-style trailing slash in copy_files#4187
Merged
Conversation
…lder contents When copying folders between buckets, a trailing `/` on the source path now uses rsync semantics: copy the *contents* of the folder into the destination without nesting the source folder itself. Without the trailing slash, the existing `cp -r` behavior is preserved (source folder nested inside destination). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
julien-c
approved these changes
May 5, 2026
Member
|
^same here, thanks! |
Contributor
|
This PR has been shipped as part of the v1.14.0 release. |
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.
Context: @Pierrci 's report in private slack. Currently it's not possible to copy the content of a folder from a bucket, to the root of another bucket.
Solution suggested by Claude:
dst/srcdst/This follows
rsyncstyle, not UNIXcpstyle so it's more of a design question rather than implementation problem. What's your take on this @hanouticelina @Pierrci @julien-c ?Before (no way to avoid nesting):
After (rsync-style trailing slash):
The implementation is a one-line condition change in
_resolve_target_path— whensource_is_contents_only(trailing/detected before parsing), the nesting step is skipped.Updated docs in CLI guide, buckets guide, CLI reference, and
copy_filesdocstring.🤖 Generated with Claude Code
Note
Medium Risk
Changes folder-copy path resolution in
HfApi.copy_filesbased on a trailing/, which could alter destination layouts for existing callers that relied on the previous nesting behavior. Covered by a new regression test, but impacts data placement in buckets.Overview
Folder copy semantics changed for buckets/repo-to-bucket copies.
HfApi.copy_filesnow treats a trailing/on the source as “copy contents only” (rsync-style), skipping the usual nesting of the source directory when the destination exists.Docs + CLI examples updated, and a new test asserts the new trailing-slash behavior when copying a folder into an existing destination directory.
Reviewed by Cursor Bugbot for commit 3562867. Bugbot is set up for automated code reviews on this repo. Configure here.