Skip to content

Always delete downloader temporary data file #2727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pkg/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,6 @@ func downloadHTTP(ctx context.Context, localPath, lastModified, contentType, url
}
logrus.Debugf("downloading %q into %q", url, localPath)

localPathTmp := perProcessTempfile(localPath)
fileWriter, err := os.Create(localPathTmp)
if err != nil {
return err
}
defer fileWriter.Close()

resp, err := httpclientutil.Get(ctx, http.DefaultClient, url)
if err != nil {
return err
Expand All @@ -631,6 +624,14 @@ func downloadHTTP(ctx context.Context, localPath, lastModified, contentType, url
hideBar(bar)
}

localPathTmp := perProcessTempfile(localPath)
fileWriter, err := os.Create(localPathTmp)
if err != nil {
return err
}
defer fileWriter.Close()
defer os.RemoveAll(localPathTmp)

writers := []io.Writer{fileWriter}
var digester digest.Digester
if expectedDigest != "" {
Expand Down
Loading