Skip to content

Commit

Permalink
releasesjson: Always remove unpacked archive
Browse files Browse the repository at this point in the history
As mentioned in #145 we never reuse the archive and so it makes sense to *always* remove it rather then collect it for removal by end-user via Remove() method.
  • Loading branch information
radeksimko committed Jan 6, 2025
1 parent 521fbd0 commit 5fb4526
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/releasesjson/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion,
if err != nil {
return nil, err
}
defer pkgFile.Close()
pkgFilePath, err := filepath.Abs(pkgFile.Name())
defer func() {
filePath := pkgFile.Name()
defer pkgFile.Close()
err = os.Remove(filePath)
if err != nil {
d.Logger.Printf("failed to delete unpacked archive at %s: %s", filePath, err)
}
d.Logger.Printf("deleted unpacked archive at %s", filePath)
}()

up = &UnpackedProduct{}
up.PathsToRemove = append(up.PathsToRemove, pkgFilePath)

d.Logger.Printf("copying %q (%d bytes) to %s", pb.Filename, expectedSize, pkgFile.Name())

Expand Down

0 comments on commit 5fb4526

Please sign in to comment.