Skip to content

Respect handler import rules when cleaning missing items - #1095

Merged
KevinJump merged 1 commit into
v18/mainfrom
port/1092-clean-respects-import-rules
Sep 15, 2026
Merged

KevinJump merged 1 commit into
v18/mainfrom
port/1092-clean-respects-import-rules

Conversation

@KevinJump

Copy link
Copy Markdown
Owner

Summary

Forward-ports v17's #1092.

  • uSync.Publisher's ExcludeContentTypes/IncludeContentTypes handler 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.
  • DeleteMissingItemsAsync now checks each delete candidate against the same ShouldImportAsync rules used on import, via a new ShouldImportDeletedItemAsync helper (serializes the item and runs it through ShouldImportAsync).
  • Reporting and real deletes now share this check, so a report can't say an item "will be deleted" when it actually wouldn't be.
  • Added HandlerSettings-aware overloads of CleanFolderAsync/DeleteMissingItemsAsync to 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 SyncHandlerRoot had already diverged from v17 (independent additions like ExportContainer, notification Force flags, action indexing). Notably, v18 already had this exact pattern on the export side - ExportDeletedItemAsync re-checks ShouldExportAsync via a ShouldExportDeletedFileAsync helper, with a reflection-cached HandlerHasShouldExportOverride() guard to skip the check when a handler doesn't override it. The new ShouldImportDeletedItemAsync here mirrors that helper's shape and naming for consistency, but does not reuse the "skip if not overridden" guard - unlike ShouldExportAsync (a no-op unless overridden), the base ShouldImportAsync always 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 errors
  • dotnet build ./uSync.slnx -c Debug — full solution, including uSync.Extend (handlers overriding the old abstract overloads still compile) — succeeds
  • dotnet test ./uSync.Tests/uSync.Tests.csproj -c Debug — 230/230 passed

🤖 Generated with Claude Code

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>
@KevinJump
KevinJump merged commit 5d0a8bd into v18/main Sep 15, 2026
1 check passed
@KevinJump
KevinJump deleted the port/1092-clean-respects-import-rules branch September 15, 2026 10:14
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