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
1 changed files with 4 additions and 1 deletions

View File

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