From 06aba85ef4864d46dc5d2d95a2306b3e38d157ee Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Fri, 5 Dec 2025 20:26:35 +1100 Subject: [PATCH] Replace ValueOnlyContext with context.WithoutCancel --- pkg/file/scan.go | 3 +-- pkg/job/manager.go | 4 ++-- pkg/utils/context.go | 22 ---------------------- 3 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 pkg/utils/context.go diff --git a/pkg/file/scan.go b/pkg/file/scan.go index 7d5a79713..4018913b0 100644 --- a/pkg/file/scan.go +++ b/pkg/file/scan.go @@ -15,7 +15,6 @@ import ( "github.com/stashapp/stash/pkg/logger" "github.com/stashapp/stash/pkg/models" "github.com/stashapp/stash/pkg/txn" - "github.com/stashapp/stash/pkg/utils" ) const ( @@ -719,7 +718,7 @@ func (s *scanJob) handleFile(ctx context.Context, f scanFile) error { // scan zip files with a different context that is not cancellable // cancelling while scanning zip file contents results in the scan // contents being partially completed - zipCtx := utils.ValueOnlyContext{Context: ctx} + zipCtx := context.WithoutCancel(ctx) if err := s.scanZipFile(zipCtx, f); err != nil { logger.Errorf("Error scanning zip file %q: %v", f.Path, err) diff --git a/pkg/job/manager.go b/pkg/job/manager.go index 983d88cc0..3e47d842b 100644 --- a/pkg/job/manager.go +++ b/pkg/job/manager.go @@ -7,7 +7,6 @@ import ( "time" "github.com/stashapp/stash/pkg/logger" - "github.com/stashapp/stash/pkg/utils" ) const maxGraveyardSize = 10 @@ -179,7 +178,8 @@ func (m *Manager) dispatch(ctx context.Context, j *Job) (done chan struct{}) { j.StartTime = &t j.Status = StatusRunning - ctx, cancelFunc := context.WithCancel(utils.ValueOnlyContext{Context: ctx}) + // create a cancellable context for the job that is not canceled by the outer context + ctx, cancelFunc := context.WithCancel(context.WithoutCancel(ctx)) j.cancelFunc = cancelFunc done = make(chan struct{}) diff --git a/pkg/utils/context.go b/pkg/utils/context.go deleted file mode 100644 index 2a3862b5d..000000000 --- a/pkg/utils/context.go +++ /dev/null @@ -1,22 +0,0 @@ -package utils - -import ( - "context" - "time" -) - -type ValueOnlyContext struct { - context.Context -} - -func (ValueOnlyContext) Deadline() (deadline time.Time, ok bool) { - return -} - -func (ValueOnlyContext) Done() <-chan struct{} { - return nil -} - -func (ValueOnlyContext) Err() error { - return nil -}