Skip to content

Commit 7b2b350

Browse files
committed
Updated downloader lib
1 parent c9d47b4 commit 7b2b350

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.bug.st/downloader/downloader.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Downloader struct {
2020
URL string
2121
Done chan bool
2222
resp *http.Response
23-
out io.Writer
23+
out *os.File
2424
completed int64
2525
size int64
2626
err error
@@ -36,7 +36,15 @@ const (
3636

3737
// Close the download
3838
func (d *Downloader) Close() error {
39-
return d.resp.Body.Close()
39+
err1 := d.out.Close()
40+
err2 := d.resp.Body.Close()
41+
if err1 != nil {
42+
return fmt.Errorf("closing output file: %s", err1)
43+
}
44+
if err2 != nil {
45+
return fmt.Errorf("closing input stream: %s", err2)
46+
}
47+
return nil
4048
}
4149

4250
// Size return the size of the download
@@ -81,8 +89,8 @@ func (d *Downloader) AsyncRun() {
8189
break
8290
}
8391
}
84-
d.Done <- true
8592
d.Close()
93+
d.Done <- true
8694
}
8795

8896
// Run starts the downloader and waits until it completes the download.

0 commit comments

Comments
 (0)