| 09-scan-cancellation-keyboard-shortcuts |
01 |
library |
| context-cancellation |
| scan-control |
| wails-binding |
| goroutine-coordination |
|
| phase |
provides |
| 08-infrastructure |
Library struct, Scan() pipeline, events system |
|
|
| CancelScan, PauseScan, ResumeScan Wails-bound methods on Library |
| IsScanActive, IsScanPaused state query methods |
| waitIfPaused internal pause checkpoint helper |
| LibraryScanCancelled, LibraryScanPaused, LibraryScanResumed events |
| ScanMetrics.Cancelled field |
|
| 09-scan-cancellation-keyboard-shortcuts |
|
| added |
patterns |
|
|
| Per-scan cancellable context (scanCtx) threaded through pipeline, app context (l.ctx) for DB ops |
| Blocking channel pattern for pause/resume (scanPauseCh closed to unblock all workers) |
| Mutex-protected scan state fields with deferred cleanup |
|
|
| created |
modified |
| backend/library/scan_control.go |
|
| backend/events/events.go |
| frontend/src/events.ts |
| backend/library/library.go |
| backend/library/metrics.go |
|
|
| scanCtx for worker cancellation, l.ctx for DB transactions — ensures in-flight commits complete |
| Blocking channel pattern for pause — workers check waitIfPaused before each extraction |
| Orphan cleanup and variant generation skipped on cancel — prevents incorrect file deletion |
|
| Per-operation cancellable context pattern: create child context at operation start, defer cancel, clean up state in defer |
| Channel-based pause/resume: create channel on pause, close on resume, select with ctx.Done for cancel-during-pause |
|
|
16min |
2026-03-07 |