mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Replace ValueOnlyContext with context.WithoutCancel
This commit is contained in:
parent
39fd8a6550
commit
06aba85ef4
3 changed files with 3 additions and 26 deletions
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
"github.com/stashapp/stash/pkg/txn"
|
"github.com/stashapp/stash/pkg/txn"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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
|
// scan zip files with a different context that is not cancellable
|
||||||
// cancelling while scanning zip file contents results in the scan
|
// cancelling while scanning zip file contents results in the scan
|
||||||
// contents being partially completed
|
// contents being partially completed
|
||||||
zipCtx := utils.ValueOnlyContext{Context: ctx}
|
zipCtx := context.WithoutCancel(ctx)
|
||||||
|
|
||||||
if err := s.scanZipFile(zipCtx, f); err != nil {
|
if err := s.scanZipFile(zipCtx, f); err != nil {
|
||||||
logger.Errorf("Error scanning zip file %q: %v", f.Path, err)
|
logger.Errorf("Error scanning zip file %q: %v", f.Path, err)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxGraveyardSize = 10
|
const maxGraveyardSize = 10
|
||||||
|
|
@ -179,7 +178,8 @@ func (m *Manager) dispatch(ctx context.Context, j *Job) (done chan struct{}) {
|
||||||
j.StartTime = &t
|
j.StartTime = &t
|
||||||
j.Status = StatusRunning
|
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
|
j.cancelFunc = cancelFunc
|
||||||
|
|
||||||
done = make(chan struct{})
|
done = make(chan struct{})
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue