1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-26 10:05:40 +00:00

Not all files will have a symlink

The linkname field in the header might not always
have a value. Need to check empty linkname.

Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
Stephen Chung 2016-07-12 09:40:45 -04:00
parent bacbea465f
commit d906a5994a

View file

@ -206,8 +206,11 @@ var (
} }
linkKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { linkKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
if sys, ok := info.Sys().(*tar.Header); ok { if sys, ok := info.Sys().(*tar.Header); ok {
if sys.Linkname != "" {
return fmt.Sprintf("link=%s", sys.Linkname), nil return fmt.Sprintf("link=%s", sys.Linkname), nil
} }
return "", nil
}
if info.Mode()&os.ModeSymlink != 0 { if info.Mode()&os.ModeSymlink != 0 {
str, err := os.Readlink(path) str, err := os.Readlink(path)