Commit 7b2b350f authored by Cristian Maglie's avatar Cristian Maglie

Updated downloader lib

parent c9d47b49
......@@ -389,11 +389,11 @@
[[projects]]
branch = "master"
digest = "1:800e8a12373d3ba53e397e356f83582722368aea8160167dfb646c26989e1f4d"
digest = "1:5cd3c0f530ab660c7b08f563020dc00b8e761c2f7650457a3f669b6601f7f28d"
name = "go.bug.st/downloader"
packages = ["."]
pruneopts = "UT"
revision = "6aab51b4c847ce8d86cff12649db295afc1739a9"
revision = "60d736642c5c2252f6d19016d7e68178b19478f0"
[[projects]]
branch = "master"
......
......@@ -20,7 +20,7 @@ type Downloader struct {
URL string
Done chan bool
resp *http.Response
out io.Writer
out *os.File
completed int64
size int64
err error
......@@ -36,7 +36,15 @@ const (
// Close the download
func (d *Downloader) Close() error {
return d.resp.Body.Close()
err1 := d.out.Close()
err2 := d.resp.Body.Close()
if err1 != nil {
return fmt.Errorf("closing output file: %s", err1)
}
if err2 != nil {
return fmt.Errorf("closing input stream: %s", err2)
}
return nil
}
// Size return the size of the download
......@@ -81,8 +89,8 @@ func (d *Downloader) AsyncRun() {
break
}
}
d.Done <- true
d.Close()
d.Done <- true
}
// Run starts the downloader and waits until it completes the download.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment