feat(task): allow retry canceled (#7852)

This commit is contained in:
KirCute_ECT
2025-01-27 20:18:10 +08:00
committed by GitHub
parent 23f3178f39
commit d5ec998699
6 changed files with 31 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package task
import (
"context"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/model"
"github.com/xhofe/tache"
"sync"
@ -66,6 +67,20 @@ func (t *TaskExtension) Ctx() context.Context {
return t.ctx
}
func (t *TaskExtension) ReinitCtx() {
if !conf.Conf.Tasks.AllowRetryCanceled {
return
}
select {
case <-t.Base.Ctx().Done():
ctx, cancel := context.WithCancel(context.Background())
t.SetCtx(ctx)
t.SetCancelFunc(cancel)
t.ctx = nil
default:
}
}
type TaskExtensionInfo interface {
tache.TaskWithInfo
GetCreator() *model.User