From 6954eefe5e0a6bcd259c0b26daaea2675487730a Mon Sep 17 00:00:00 2001 From: wesley800 Date: Thu, 15 Sep 2022 13:28:04 +0800 Subject: [PATCH] properly truncate dest file in util.CopyFile --- internal/pkg/util/copyfile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/util/copyfile.go b/internal/pkg/util/copyfile.go index 5c858e48..ef47b890 100644 --- a/internal/pkg/util/copyfile.go +++ b/internal/pkg/util/copyfile.go @@ -27,7 +27,7 @@ func CopyFile(src string, dst string) error { return err } - dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, srcInfo.Mode()) + dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, srcInfo.Mode()) if err != nil { wwlog.Error("Could not create destination file %s: %s\n", dst, err) return err