Repository navigation
fix: sync --delete respects --exclude and --include (#815) - #883
Open
terryrankine wants to merge 1 commit into
Open
terryrankine wants to merge 1 commit into
terryrankine wants to merge 1 commit into
Conversation
3 of 7 tasks
Objects that exist only in the destination were deleted even when they matched an --exclude pattern or did not match an --include pattern. The generated rm command did receive the patterns, but rm runs in raw mode and matched them against the full object key, so a pattern like "folder/*" never matched under a destination prefix. sync now filters the delete candidates itself, relative to the destination prefix, and omits --exclude/--include from the generated rm command. generateCommand treats a nil default flag value as "omit this flag". Fixes peak#815 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
terryrankine
force-pushed
the
fix/sync-delete-filters
branch
from
September 17, 2026 19:54
ab3b04a to
c281acb
Compare
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
Fixes #815.
sync --deletedeleted destination objects that--excludeshould have protected, and with--includeit deleted nothing at all.Root cause
syncforwarded--exclude/--includeto the generatedrm --raw …command. Raw URLs have an empty prefix, sormmatched the patterns against the full object key rather than the path relative to the destination prefix. Suffix patterns like*.txthappened to work;folder/*never matched; and because--includethen matched nothing, thermwas a no-op.Fix
Sync.Runcompiles the patterns once (same error handling ascp).planRunfilters the delete candidates withisURLMatched(patterns, d.Path, dsturl.Prefix)— relative to the destination prefix, like every other command.generateCommandnow omits a default flag whose value isnil; thermcommand is built withexclude: nil, include: nilso it is not re-filtered.--delete.Tests
command/context_test.go: nil default flags are omitted even when set in the context.e2e/sync_test.go:sync --delete --exclude "sub/*"keepssub/keep.txtand deletesold.log;--include "*.md" --include "sub/*"deletes only matching objects. Both fail onmasterand pass with this change.Linux, Go 1.24,
go test -count=1 -race ./...: all packagesok.gofmt,go vet,staticcheck,unparam,semgrep: clean.🤖 Generated with Claude Code