Skip to content

Commit

Permalink
fix: Add symbolic link changes to Hasher and CacheHasher
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx committed May 12, 2022
1 parent e0b84c5 commit acc64db
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func Hasher() func(string) (string, error) {
if _, err := io.CopyBuffer(h, f, *buf); err != nil {
return "", err
}
} else if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
linkPath, err := os.Readlink(p)
if err != nil {
return "", err
}
h.Write([]byte(linkPath))
}

return hex.EncodeToString(h.Sum(nil)), nil
Expand Down Expand Up @@ -101,6 +107,12 @@ func CacheHasher() func(string) (string, error) {
if _, err := io.Copy(h, f); err != nil {
return "", err
}
} else if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
linkPath, err := os.Readlink(p)
if err != nil {
return "", err
}
h.Write([]byte(linkPath))
}

return hex.EncodeToString(h.Sum(nil)), nil
Expand Down

0 comments on commit acc64db

Please sign in to comment.