From 8759eaf09ece8dbd077cc6d8903ce7a2ea6108cc Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Wed, 28 Aug 2024 13:44:05 +0200 Subject: [PATCH] Truncate files if they exist prior to extraction from archive 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 f8ea4d226..e0675f99f 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 }