Skip to content

Commit

Permalink
releasesjson: Always remove unpacked archive (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko authored Jan 6, 2025
1 parent 521fbd0 commit 5e5f5cc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/releasesjson/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,18 @@ 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() {
pkgFile.Close()
filePath := pkgFile.Name()
err = os.Remove(filePath)
if err != nil {
d.Logger.Printf("failed to delete unpacked archive at %s: %s", filePath, err)
return
}
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 5e5f5cc

Please sign in to comment.