File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -306,7 +306,7 @@ func (d *Downloader) UnregisterPeer(id string) error {
306306 d .cancelLock .RUnlock ()
307307
308308 if master {
309- d .Cancel ()
309+ d .cancel ()
310310 }
311311 return nil
312312}
@@ -501,8 +501,10 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
501501 return err
502502}
503503
504- // Cancel cancels all of the operations and resets the queue.
505- func (d * Downloader ) Cancel () {
504+ // cancel aborts all of the operations and resets the queue. However, cancel does
505+ // not wait for the running download goroutines to finish. This method should be
506+ // used when cancelling the downloads from inside the downloader.
507+ func (d * Downloader ) cancel () {
506508 // Close the current cancel channel
507509 d .cancelLock .Lock ()
508510 if d .cancelCh != nil {
@@ -514,6 +516,12 @@ func (d *Downloader) Cancel() {
514516 }
515517 }
516518 d .cancelLock .Unlock ()
519+ }
520+
521+ // Cancel aborts all of the operations and waits for all download goroutines to
522+ // finish before returning.
523+ func (d * Downloader ) Cancel () {
524+ d .cancel ()
517525 d .cancelWg .Wait ()
518526}
519527
You can’t perform that action at this time.
0 commit comments