mirror of
https://github.com/bit1001/tdl.git
synced 2024-09-20 06:35:54 +08:00
fix(ctx): consider ctx done
This commit is contained in:
parent
7139f4200f
commit
216ad34f61
|
@ -88,6 +88,12 @@ func (d *Downloader) Download(ctx context.Context, limit int) error {
|
|||
}
|
||||
|
||||
func (d *Downloader) download(ctx context.Context, item *Item) error {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
tracker := prog.AppendTracker(d.pw, formatter, item.Name, item.Size)
|
||||
filename := fmt.Sprintf("%s%s", utils.FS.GetNameWithoutExt(item.Name), TempExt)
|
||||
path := filepath.Join(consts.DownloadPath, filename)
|
||||
|
|
|
@ -87,6 +87,12 @@ func (u *Uploader) upload(ctx context.Context, item *Item) error {
|
|||
_ = R.Close()
|
||||
}(item.R)
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
tracker := prog.AppendTracker(u.pw, formatter, item.Name, item.Size)
|
||||
|
||||
up := uploader.NewUploader(u.client).
|
||||
|
|
Loading…
Reference in a new issue