mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-19 23:03:43 +00:00
refactor: fetcher模型
This commit is contained in:
1 parent
eee6112be5
commit
f150ec23c4
9 files changed
+297
-207
No files matched your search
@@ -81,13 +81,20 @@ func (d *Downloader) Create(res *base.Resource, opts *base.Options) (err error)
|
||||
fetcher: fetcher,
|
||||
locker: new(sync.Mutex),
|
||||
}
|
||||
d.emit(d.tasks[id], base.DownloadStatusStart)
|
||||
go func() {
|
||||
err = fetcher.Start()
|
||||
if err != nil {
|
||||
d.emit(d.tasks[id], base.DownloadStatusError)
|
||||
return
|
||||
}
|
||||
err = fetcher.Wait()
|
||||
if err != nil {
|
||||
d.emit(d.tasks[id], base.DownloadStatusError)
|
||||
} else {
|
||||
d.emit(d.tasks[id], base.DownloadStatusDone)
|
||||
}
|
||||
}()
|
||||
d.emit(d.tasks[id], base.DownloadStatusStart)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user