From acc64db991621dd9be838800a352f8d661a9f2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Thu, 12 May 2022 23:34:23 +0200 Subject: [PATCH] fix: Add symbolic link changes to Hasher and CacheHasher --- pkg/util/util.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/util/util.go b/pkg/util/util.go index 9387dd029c..cafb1ed02c 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -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 @@ -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