Overview of PAR2 Repair Cancellation
mainThe PAR2 repair cancellation feature allows users to stop queued or in-flight PAR2 repairs from the Health page. The system ensures that all transient scratch and temporary artifacts are provably deleted before the API responds to the cancellation request.
Key Architectural Components:
par2repair.Service: Maintains an in-process registry of active jobs. Each job is tracked with acontext.CancelFuncand adonechannel.- Cancellation Flow: Calling
Canceltriggers the job's context cancellation. The system waits for the worker goroutine to unwind, ensuring thatRunJob's arenadeferstatements execute (which delete mmap scratch files) before the service sweeps any remaining orphaned scratch/tmp files. - Bookkeeping: The worker goroutine is responsible for terminal bookkeeping (e.g., failing parked imports, deleting rows) to ensure a single owner for state transitions.