From 3b3b255e3e6c911c3be72e4669d1a3f0db9287b3 Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Thu, 29 Aug 2024 16:41:58 +0200 Subject: [PATCH] Truncate files if they exist prior to extraction from archive (#1245) Signed-off-by: Slavek Kabrda --- pkg/repo/repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index c866dc64a..ec75cec25 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -270,7 +270,7 @@ func Uncompress(src io.Reader, dst string) error { } // Write out files case tar.TypeReg: - fileToWrite, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode)) + fileToWrite, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.FileMode(header.Mode)) if err != nil { return err }