fix(app): fold Create/DeleteSmartCollection into the post-commit None sweep (#254 review)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m27s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 10m0s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 35s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m27s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 10m0s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 35s
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,10 @@ public class DeleteSmartCollectionHandler : IRequestHandler<DeleteSmartCollectio
|
||||
dbContext.SmartCollections.Remove(smartCollection);
|
||||
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 Unit.Default;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user