refactor(scraper): Phase 4 — cross-cutting CancellationToken propagation#737
Merged
astar-development-jb merged 2 commits intoJul 12, 2026
Merged
Conversation
#736) ConfigurationSaver, DataSeed, and DatabaseInitializationService must accept and propagate a CancellationToken. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…igurationSaver, DataSeed, and DatabaseInitializationService (#736) ConfigurationSaver.SaveUpdatedConfigurationAsync now requires a token and passes it to CreateDbContextAsync, SingleAsync, and SaveChangesAsync via the token-aware Try.RunAsync overload. All four call sites (PagedScrapeRunner, SearchWorkflow, TopWallpapersWorkflow, SubscriptionsWorkflow) forward their workflow token. DataSeed methods and DatabaseInitializationService.InitialiseAsync accept and propagate tokens, and initialisation now uses CreateDbContextAsync. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Test results3 149 tests - 20 3 147 ✅ - 21 1m 4s ⏱️ - 1m 12s For more details on these failures, see this check. Results for commit 91aeee8. ± Comparison against base commit 83beb20. This pull request removes 27 and adds 7 tests. Note that renamed tests count towards both. |
astar-development-jb
enabled auto-merge (squash)
July 12, 2026 03:59
astar-development-jb
approved these changes
Jul 12, 2026
astar-development-jb
deleted the
feature/scraper-phase4-cancellation-tokens
branch
July 12, 2026 04:00
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
Implements Phase 4 (cross-cutting items 13–14) of
docs/astar-dev-wallpaper-scraper/code-review-2026-07-10.v2.md:ConfigurationSaver.SaveUpdatedConfigurationAsyncnow requires aCancellationTokenand passes it toCreateDbContextAsync,SingleAsync, andSaveChangesAsync, using the token-awareTry.RunAsync(operation, cancellationToken)overload. All four call sites (PagedScrapeRunner,SearchWorkflow,TopWallpapersWorkflow,SubscriptionsWorkflow) forward their workflow token.DataSeed.SeedTagsToIgnoreAsync/SeedScrapeConfigurationAsync/SeedFileClassificationsAsyncaccept and propagate a token (SaveChangesAsync,File.ReadAllLinesAsync).DatabaseInitializationService.InitialiseAsync(CancellationToken = default)propagates toCreateDbContextAsync,MigrateAsync, and the seed calls; also switches from syncCreateDbContext()toCreateDbContextAsync.ScrapeConfigurationService.UpdateConnectionStrings/UpdateUserConfiguration/UpdateSearchConfiguration/UpdateScrapeDirectories/UpsertSearchCategories); verified, no change needed.Out of scope, flagged for follow-up:
ScrapeConfigurationViewModel(UI layer; long-lived context, underscore-prefixed fields) andMainWindow.axaml.csCancellationToken.Nonein UI event handlers.Type of change
Related issues / links
Closes #736. Follows #735 (Phase 3), #730/#728/#727/#726 (Phase 2), #721 (Phase 1).
How was this tested?
Failing tests committed first (TDD), then production code. New tests: token-passed-to-factory and cancelled-token behaviour for
ConfigurationSaver,DataSeed(all three seed methods), andDatabaseInitializationService.dotnet clean && dotnet build --no-restore: 0 errors. 8 warnings, all pre-existing on main (NU1903 vulnerableSQLitePCLRaw.lib.e_sqlite3inspikes/, AVLN3001 Avalonia XAML resources) — none in the changed projects.dotnet test --no-build: 3,176 total, 0 failed, 1 skipped (pre-existing skip inAStar.Dev.Utilities.Tests.Unit). Scraper unit project: 448 passed, 0 failed (7 new tests).Impacted areas
apps/desktop/Scraper/AStar.Dev.Wallpaper.Scraper, apps/desktop/Scraper/AStar.Dev.Wallpaper.Scraper.Tests.Unit
TDD Checklist (required)
dotnet test)How to run tests locally
Notes for reviewers
SaveUpdatedConfigurationAsynctoken parameter is required (no default) so future call sites must propagate;InitialiseAsynckeeps= defaultbecause the app-startup caller has no token source.Try.RunAsyncrethrowsOperationCanceledExceptionrather than converting it to aFailresult — this matches the documented behaviour of the token-aware overload.🤖 Generated with Claude Code