Skip to content

Commit 42cf896

Browse files
committed
fix: Allow overwriting when untarring
1 parent 05dd6ce commit 42cf896

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/tar.go

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io/fs"
88
"os"
99
"path/filepath"
10+
"strings"
1011
)
1112

1213
func ExtractTarStream(r io.Reader, targetPath string) error {
@@ -39,6 +40,7 @@ func ExtractTarStream(r io.Reader, targetPath string) error {
3940
return fmt.Errorf("ExtractTarStream: Mkdir() failed: %w", err)
4041
}
4142
case tar.TypeReg:
43+
_ = os.Remove(p) // we allow overwriting, which easily happens on case insensitive filesystems
4244
outFile, err := os.Create(p)
4345
if err != nil {
4446
return fmt.Errorf("ExtractTarStream: Create() failed: %w", err)
@@ -57,6 +59,7 @@ func ExtractTarStream(r io.Reader, targetPath string) error {
5759
return err
5860
}
5961
case tar.TypeSymlink:
62+
_ = os.Remove(p) // we allow overwriting, which easily happens on case insensitive filesystems
6063
if err := os.Symlink(header.Linkname, p); err != nil {
6164
return fmt.Errorf("ExtractTarStream: Symlink() failed: %w", err)
6265
}

0 commit comments

Comments
 (0)