Improve error handling and close files post-tarring

This commit is contained in:
Kegan Dougal 2021-07-08 10:07:39 +01:00
parent f2974721d5
commit 717d16345c
2 changed files with 8 additions and 1 deletions

View file

@ -104,6 +104,7 @@ func downloadArchive(cli *http.Client, tmpDir, archiveURL string, dockerfile []b
if resp.StatusCode != 200 {
return nil, fmt.Errorf("got HTTP %d", resp.StatusCode)
}
_ = os.RemoveAll(tmpDir)
if err = os.Mkdir(tmpDir, os.ModePerm); err != nil {
return nil, fmt.Errorf("failed to make temporary directory: %s", err)
}