Don't cleanup the whole cache download dir, just the downloaded artifact

Otherwise whatever we download cannot be consumed (e.g. tree).
Instead whoever is calling the client should care to cleanup the returned artifact
This commit is contained in:
Ettore Di Giacinto 2020-01-30 18:03:25 +01:00
parent eee0136156
commit 0147b2cf99
No known key found for this signature in database
GPG Key ID: 1ADA699B145A2D1C

View File

@ -49,7 +49,6 @@ func (c *HttpClient) DownloadArtifact(artifact compiler.Artifact) (compiler.Arti
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer os.RemoveAll(temp)
file, err = ioutil.TempFile(temp, "HttpClient") file, err = ioutil.TempFile(temp, "HttpClient")
if err != nil { if err != nil {
@ -75,6 +74,8 @@ func (c *HttpClient) DownloadArtifact(artifact compiler.Artifact) (compiler.Arti
if err != nil { if err != nil {
continue continue
} }
defer os.RemoveAll(filepath.Join(temp, artifactName))
ok = true ok = true
break break
} }