diff --git a/pkg/file/scan.go b/pkg/file/scan.go index 31cd50af6..18c1955d2 100644 --- a/pkg/file/scan.go +++ b/pkg/file/scan.go @@ -14,6 +14,7 @@ import ( "github.com/remeh/sizedwaitgroup" "github.com/stashapp/stash/pkg/logger" "github.com/stashapp/stash/pkg/txn" + "github.com/stashapp/stash/pkg/utils" ) const ( @@ -574,7 +575,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 := context.Background() + zipCtx := utils.ValueOnlyContext{Context: 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/context.go b/pkg/job/context.go deleted file mode 100644 index e53625e23..000000000 --- a/pkg/job/context.go +++ /dev/null @@ -1,22 +0,0 @@ -package job - -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 -} diff --git a/pkg/job/manager.go b/pkg/job/manager.go index ce5fd4f9d..4ad9b1880 100644 --- a/pkg/job/manager.go +++ b/pkg/job/manager.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stashapp/stash/pkg/logger" + "github.com/stashapp/stash/pkg/utils" ) const maxGraveyardSize = 10 @@ -178,7 +179,7 @@ func (m *Manager) dispatch(ctx context.Context, j *Job) (done chan struct{}) { j.StartTime = &t j.Status = StatusRunning - ctx, cancelFunc := context.WithCancel(valueOnlyContext{ctx}) + ctx, cancelFunc := context.WithCancel(utils.ValueOnlyContext{Context: ctx}) j.cancelFunc = cancelFunc done = make(chan struct{}) diff --git a/pkg/utils/context.go b/pkg/utils/context.go new file mode 100644 index 000000000..2a3862b5d --- /dev/null +++ b/pkg/utils/context.go @@ -0,0 +1,22 @@ +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 +}