Add --if-exists=autorename for cp, mv, and put#337
Merged
Conversation
Wire the SDK's server-side autorename into the conflict-handling flag: RelocationArg.Autorename for cp/mv and CommitInfo.Autorename for put. When a conflict causes the server to store the object under a new path, report a distinct "autorenamed" status (mirroring how "skip" reports "skipped"); otherwise the normal copied/moved/uploaded status is kept. Dropbox paths are case-insensitive and case-preserving, so the server may return a differently-cased path without actually autorenaming. Compare paths with a shared sameDropboxMetadataPath helper that prefers path_lower and folds case, so a case-only difference is not reported as a rename. Consolidate the sameDropboxPath helper into metadata.go so the relocation/put status logic and share-link create can share it. Update the help manifest, generated command docs, and JSON schemas, and add behavior tests asserting the SDK flag is set, the status reflects whether a rename actually occurred, and case-only paths stay unchanged.
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.
Summary
Adds
autorenameas a new--if-existsoption forcp,mv, andput, wiring the Dropbox SDK's server-side autorename into the existing conflict-handling flag.cp/mv: setsRelocationArg.Autorenameput: setsCommitInfo.AutorenameWhen a destination conflict causes the server to store the object under a new path, the command reports a distinct
autorenamedJSON status — mirroring howskipalready reportsskipped. When no conflict occurs, the normalcopied/moved/uploadedstatus is kept.Case-insensitivity handling
Dropbox paths are case-insensitive and case-preserving, so the server can return a differently-cased path (e.g.
/Dest/File.txtfor a requested/dest/file.txt) without actually autorenaming. Path comparison goes through a sharedsameDropboxMetadataPathhelper that preferspath_lowerand folds case, so a case-only difference is not reported as a rename. ThesameDropboxPathhelper was consolidated intometadata.goso the relocation/put status logic and share-link create share one implementation.Docs & schema
docs/commands/), and regenerated the JSON schemas (docs/json-schema/v1/).