From 6055bd368738e82c2e5ccdd259a45940cb51209f Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 11 Jul 2026 17:49:16 +0200 Subject: [PATCH] fix(app): fold Create/DeleteSmartCollection into the post-commit None sweep (#254 review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Independent adversarial review of PR #266 found two sibling handlers with the identical post-commit `_smartCollectionCache.Refresh(cancellationToken)` pattern that the sweep missed (only UpdateSmartCollection was caught). Same audit#22 F4 class: a late client-disconnect after the commit lands would throw and leave the in-memory smart-collection cache stale vs the committed DB. → CancellationToken.None. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Commands/CreateSmartCollectionHandler.cs | 5 ++++- .../Commands/DeleteSmartCollectionHandler.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ErsatzTV.Application/MediaCollections/Commands/CreateSmartCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/CreateSmartCollectionHandler.cs index 5a9783c45..33ed35131 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/CreateSmartCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/CreateSmartCollectionHandler.cs @@ -42,7 +42,10 @@ public class CreateSmartCollectionHandler : await dbContext.SmartCollections.AddAsync(smartCollection, cancellationToken); await dbContext.SaveChangesAsync(cancellationToken); _searchTargets.SearchTargetsChanged(); - await _smartCollectionCache.Refresh(cancellationToken); + + // post-commit side effect runs on CancellationToken.None so a late request cancellation + // can't abort it after the commit landed (#254) + await _smartCollectionCache.Refresh(CancellationToken.None); return ProjectToViewModel(smartCollection); } diff --git a/ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollectionHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollectionHandler.cs index 7fdea22d6..2b6e849a8 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollectionHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/DeleteSmartCollectionHandler.cs @@ -48,7 +48,10 @@ public class DeleteSmartCollectionHandler : IRequestHandler