summaryrefslogtreecommitdiff
path: root/player-server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-19 14:58:20 +0300
committerPaul Buetow <paul@buetow.org>2026-05-19 14:58:20 +0300
commitebb88acd66a815c07fa8adedca052182d0cb8cc5 (patch)
treee010c1d49b3d38c1e0351705937304e3225fc5fc /player-server
parent0d737e7585a7b6876679b266e677675f7787ff24 (diff)
Pass scanCtx to probeFile so ffprobe cancels with the scan
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.
Diffstat (limited to 'player-server')
-rw-r--r--player-server/internal/scanner/scanner.go6
1 files changed, 5 insertions, 1 deletions
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