Skip to content

Commit

Permalink
Enable overwriting of links (solves #351)
Browse files Browse the repository at this point in the history
  • Loading branch information
xanonid committed Sep 26, 2018
1 parent bb0df68 commit a083e7c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error {
if err := os.MkdirAll(dir, 0755); err != nil {
return err
}
// Check if something already exists at path
// If so, delete it
if FilepathExists(path) {
if err := os.Remove(path); err != nil {
return errors.Wrapf(err, "error removing %s to make way for new link", hdr.Name)
}
}

if err := os.Link(filepath.Clean(filepath.Join("/", hdr.Linkname)), path); err != nil {
return err
}
Expand Down

0 comments on commit a083e7c

Please sign in to comment.