Respect handler import rules when cleaning missing items - #1095
Merged
Merged
Conversation
uSync.Publisher's ExcludeContentTypes / IncludeContentTypes handler settings were only applied when importing files - a 'clean' delete missing items pass ignored them, so items never sent by a partial sync (e.g. an excluded doc type) were treated as missing and deleted. DeleteMissingItemsAsync now runs each delete candidate through the same ShouldImportAsync rules used on import, via a new ShouldImportDeletedItemAsync helper that serializes the item and checks it. Reporting and real deletes use the same check so a report can no longer say an item 'will be deleted' when it actually won't. New HandlerSettings-aware overloads of CleanFolderAsync and DeleteMissingItemsAsync carry the config through; the old overloads are marked Obsolete (removal in v20) rather than changed, to avoid breaking existing overrides. Forward-port of v17's #1092, adapted to v18's SyncHandlerRoot: the new ShouldImportDeletedItemAsync mirrors the existing ShouldExportDeletedFileAsync pattern already used for the export side of the same problem. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Sep 24, 2026
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
Forward-ports v17's #1092.
ExcludeContentTypes/IncludeContentTypeshandler settings were only applied when importing files. The 'clean' delete-missing-items pass ignored them, so a partial sync (e.g. some doc types excluded) would delete items on the target it simply never sent.DeleteMissingItemsAsyncnow checks each delete candidate against the sameShouldImportAsyncrules used on import, via a newShouldImportDeletedItemAsynchelper (serializes the item and runs it throughShouldImportAsync).HandlerSettings-aware overloads ofCleanFolderAsync/DeleteMissingItemsAsyncto carry the config through. Old overloads are marked[Obsolete](removal in v20) and forward to the new ones, rather than being changed in place, to avoid breaking existing overrides.Adapted for v18, not a direct port: v18's
SyncHandlerRoothad already diverged from v17 (independent additions likeExportContainer, notificationForceflags, action indexing). Notably, v18 already had this exact pattern on the export side -ExportDeletedItemAsyncre-checksShouldExportAsyncvia aShouldExportDeletedFileAsynchelper, with a reflection-cachedHandlerHasShouldExportOverride()guard to skip the check when a handler doesn't override it. The newShouldImportDeletedItemAsynchere mirrors that helper's shape and naming for consistency, but does not reuse the "skip if not overridden" guard - unlikeShouldExportAsync(a no-op unless overridden), the baseShouldImportAsyncalways does real work (CreateOnly,IgnoreAliases), so the check always needs to run.Test plan
dotnet build ./uSync.BackOffice/uSync.BackOffice.csproj -c Debug— succeeds, 0 warnings, 0 errorsdotnet build ./uSync.slnx -c Debug— full solution, includinguSync.Extend(handlers overriding the old abstract overloads still compile) — succeedsdotnet test ./uSync.Tests/uSync.Tests.csproj -c Debug— 230/230 passed🤖 Generated with Claude Code