From ebb88acd66a815c07fa8adedca052182d0cb8cc5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 19 May 2026 14:58:20 +0300 Subject: Pass scanCtx to probeFile so ffprobe cancels with the scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit probeWorkerLoop was passing the parent ctx into probeFile, which in turn passed it to prober.Probe (ffprobe) and thumbGen.Generate (ffmpeg). When scanCtx was cancelled — because another worker failed or TriggerRescan restarted the scan — those subprocesses kept running until the parent ctx was cancelled. Switching to scanCtx makes them stop promptly. Kept writerLoop's store.CreateMedia on the parent ctx: the scanCtx.Err() guard at the top of the loop already prevents new writes after cancel, and any in-flight CreateMedia should complete so the DB stays consistent with what was probed. --- player-server/internal/scanner/scanner.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'player-server') diff --git a/player-server/internal/scanner/scanner.go b/player-server/internal/scanner/scanner.go index 9eb5b1e..9233630 100644 --- a/player-server/internal/scanner/scanner.go +++ b/player-server/internal/scanner/scanner.go @@ -498,7 +498,11 @@ func (s *FSScanner) probeWorkerLoop( if scanCtx.Err() != nil { continue } - result, err := s.probeFile(ctx, path, setPath, setID, setName, existing, coverImages, progress) + // Use scanCtx (not ctx) so ffprobe/ffmpeg subprocesses spawned by + // probeFile cancel promptly when scanCtx is cancelled — e.g. another + // worker failed or TriggerRescan restarted the scan. Passing the + // parent ctx here would leave ffprobe running after cancel. + result, err := s.probeFile(scanCtx, path, setPath, setID, setName, existing, coverImages, progress) if err != nil { sendErr(err) return -- cgit v1.2.3