Skip to content

Add --if-exists=autorename for cp, mv, and put#337

Merged
AndreyVMarkelov merged 1 commit into
masterfrom
feature/if-exists-autorename
Jul 7, 2026
Merged

Add --if-exists=autorename for cp, mv, and put#337
AndreyVMarkelov merged 1 commit into
masterfrom
feature/if-exists-autorename

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds autorename as a new --if-exists option for cp, mv, and put, wiring the Dropbox SDK's server-side autorename into the existing conflict-handling flag.

  • cp/mv: sets RelocationArg.Autorename
  • put: sets CommitInfo.Autorename

When a destination conflict causes the server to store the object under a new path, the command reports a distinct autorenamed JSON status — mirroring how skip already reports skipped. When no conflict occurs, the normal copied/moved/uploaded status 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.txt for a requested /dest/file.txt) without actually autorenaming. Path comparison goes through a shared sameDropboxMetadataPath helper that prefers path_lower and folds case, so a case-only difference is not reported as a rename. The sameDropboxPath helper was consolidated into metadata.go so the relocation/put status logic and share-link create share one implementation.

Docs & schema

  • Updated the help manifest, regenerated command docs (docs/commands/), and regenerated the JSON schemas (docs/json-schema/v1/).

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.
@AndreyVMarkelov AndreyVMarkelov merged commit 8704e23 into master Jul 7, 2026
13 checks passed
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.

1 participant