From 61f22df6327b1e6cfe2d9a62d6b1c34dc2d84a75 Mon Sep 17 00:00:00 2001 From: Danny van der Meulen Date: Mon, 22 Jan 2024 06:51:33 +0100 Subject: [PATCH] Add symlink support to untar. (#43) Fixes: #42 Adds support for creating symlinks when untarring ansible tarball. --- unarchive.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unarchive.go b/unarchive.go index 050c4b3..7f79183 100644 --- a/unarchive.go +++ b/unarchive.go @@ -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 {