mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 05:43:41 +00:00
临时提交
This commit is contained in:
1 parent
3215955056
commit
871185e7ea
5 files changed
+36
-15
No files matched your search
@@ -20,6 +20,7 @@ type Process struct {
|
||||
chunks []*model.Chunk
|
||||
|
||||
pauseCond *sync.Cond
|
||||
eventCh chan common.Event
|
||||
}
|
||||
|
||||
func NewProcess(fetcher *Fetcher, res *common.Resource, opts *common.Options) *Process {
|
||||
@@ -33,6 +34,11 @@ func NewProcess(fetcher *Fetcher, res *common.Resource, opts *common.Options) *P
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Process) Listen() <-chan common.Event {
|
||||
p.eventCh = make(chan common.Event)
|
||||
return p.eventCh
|
||||
}
|
||||
|
||||
func (p *Process) Start() error {
|
||||
ctl := p.fetcher.GetCtl()
|
||||
// 创建文件
|
||||
@@ -68,6 +74,7 @@ func (p *Process) Start() error {
|
||||
p.clients = make([]*http.Response, 1)
|
||||
p.chunks[0] = model.NewChunk(0, 0)
|
||||
}
|
||||
p.dispatch(common.DownloadStatusStart)
|
||||
return p.fetch()
|
||||
}
|
||||
|
||||
@@ -243,3 +250,9 @@ func (p *Process) fetchChunk(index int, name string, chunk *model.Chunk) (err er
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *Process) dispatch(status common.Status) {
|
||||
if p.eventCh != nil {
|
||||
p.eventCh <- &Event{status: status}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user