Skip to content

Commit

Permalink
Add symlink support to untar. (#43)
Browse files Browse the repository at this point in the history
Fixes: #42 

Adds support for creating symlinks when untarring ansible tarball.
  • Loading branch information
dmeulen authored Jan 22, 2024
1 parent 9359b73 commit 61f22df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions unarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func extractTgz(src, dest string) error {
targetPath := filepath.Join(dest, header.Name)

switch header.Typeflag {
case tar.TypeSymlink:
if err := os.Symlink(header.Linkname, targetPath); err != nil {
return errors.Wrap(err, "unable to create symlink from tar")
}

case tar.TypeDir:
if _, err := os.Stat(targetPath); os.IsNotExist(err) {
if err := os.Mkdir(targetPath, 0755); err != nil {
Expand Down

0 comments on commit 61f22df

Please sign in to comment.