simplify
This commit is contained in:
parent
953c3be60a
commit
052bd7c190
|
@ -67,19 +67,20 @@ func (us UploadScheduler[K]) Prepare(k K, timeout time.Duration, cb func(K, erro
|
||||||
return errors.New("upload key already exists")
|
return errors.New("upload key already exists")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d := time.Second * time.Duration(timeout)
|
||||||
|
|
||||||
|
f := func() {
|
||||||
|
if _, ok := us.m.Get(k); ok {
|
||||||
|
err := us.Finish(k)
|
||||||
|
cb(k, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
us.m.Set(
|
us.m.Set(
|
||||||
k,
|
k,
|
||||||
upload{
|
upload{
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
timer: time.AfterFunc(
|
timer: time.AfterFunc(d, f),
|
||||||
time.Second*time.Duration(timeout),
|
|
||||||
func() {
|
|
||||||
if _, ok := us.m.Get(k); ok {
|
|
||||||
err := us.Finish(k)
|
|
||||||
cb(k, err)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue