Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue when reading symlink during tar Archive #201

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions archiver.go
Expand Up @@ -105,6 +105,9 @@ type Extractor interface {
type File struct {
os.FileInfo

// OriginalPath is the original full path to file
OriginalPath string

// The original header info; depends on
// type of archive -- could be nil, too.
Header interface{}
Expand Down
3 changes: 2 additions & 1 deletion tar.go
Expand Up @@ -295,6 +295,7 @@ func (t *Tar) writeWalk(source, topLevelFolder, destination string) error {
FileInfo: info,
CustomName: nameInArchive,
},
OriginalPath: fpath,
ReadCloser: file,
})
if err != nil {
Expand Down Expand Up @@ -340,7 +341,7 @@ func (t *Tar) Write(f File) error {
var linkTarget string
if isSymlink(f) {
var err error
linkTarget, err = os.Readlink(f.Name())
linkTarget, err = os.Readlink(f.OriginalPath)
if err != nil {
return fmt.Errorf("%s: readlink: %v", f.Name(), err)
}
Expand Down