Fix fetcher not close file descriptor correctly (#889)

* Fix fetcher not close file descriptor correctly
* Call Sync() before chmod
This commit is contained in:
Ta-Ching Chen
2018-09-11 14:15:56 +08:00
committed by GitHub
parent a4f58fbf10
commit 82d23b9bf8
+9
View File
@@ -105,10 +105,19 @@ func downloadUrl(url string, localPath string) error {
if err != nil {
return err
}
defer w.Close()
_, err = io.Copy(w, resp.Body)
if err != nil {
return err
}
// flushing write buffer to file
err = w.Sync()
if err != nil {
return err
}
err = os.Chmod(localPath, 0600)
if err != nil {
return err