Skip to content

Add --if-exists fail|skip to cp and mv commands#304

Merged
AndreyVMarkelov merged 1 commit into
masterfrom
feat/cp-mv-if-exists
Jun 28, 2026
Merged

Add --if-exists fail|skip to cp and mv commands#304
AndreyVMarkelov merged 1 commit into
masterfrom
feat/cp-mv-if-exists

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add --if-exists fail|skip flag to both cp and mv commands (default: fail)
  • Pre-flight GetMetadata check skips destinations that already exist when --if-exists skip
  • Post-flight conflict recovery converts destination-conflict API errors to skips (handles races)
  • JSON output reports per-item "skipped" status alongside "copied" / "moved"
  • Text mode is silent for skipped items

Test plan

  • go test ./cmd/... passes
  • golangci-lint run clean
  • dbxcli cp --if-exists skip /src /existing-dest skips without error
  • dbxcli mv --if-exists skip /src /existing-dest skips without error
  • dbxcli cp --if-exists fail /src /existing-dest fails (default behavior)
  • dbxcli cp --if-exists invalid /src /dest returns validation error
  • Multi-source cp --if-exists skip applies per-target independently

Allow cp and mv to skip destinations that already exist instead of
failing. Uses pre-flight GetMetadata check plus post-flight conflict
recovery to handle races. JSON output reports per-item "skipped" status.
@AndreyVMarkelov AndreyVMarkelov merged commit 509bf8a into master Jun 28, 2026
8 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