Replace ValueOnlyContext with context.WithoutCancel

This commit is contained in:
WithoutPants 2025-12-05 20:26:35 +11:00
parent 39fd8a6550
commit 06aba85ef4
3 changed files with 3 additions and 26 deletions

View file

@ -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)

View file

@ -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{})

View file

@ -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
}