properly close http response

This commit is contained in:
Chris Lu
2020-02-14 09:09:15 -08:00
parent 9b6296e77a
commit cf5064d702
5 changed files with 18 additions and 10 deletions

View File

@@ -71,6 +71,7 @@ func downloadToFile(server, fileId, saveDir string) error {
}
f, err := os.OpenFile(path.Join(saveDir, filename), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
if err != nil {
io.Copy(ioutil.Discard, rc)
return err
}
defer f.Close()