From 94ae6c8e796678075e93b12c248e171ad3dbbd11 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 3 Apr 2023 14:06:19 -0400 Subject: [PATCH] feat(backend/utils): follow symlink to get file contents --- server/backend/utils.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/backend/utils.go b/server/backend/utils.go index ed68a88dd..c6cdff4db 100644 --- a/server/backend/utils.go +++ b/server/backend/utils.go @@ -29,12 +29,24 @@ func LatestFile(r Repository, pattern string) (string, string, error) { return "", "", err } for _, e := range ents { - fp := filepath.Join(dir, e.Name()) - if e.IsTree() { + te := e + fp := filepath.Join(dir, te.Name()) + if te.IsTree() { continue } if g.Match(fp) { - bts, err := e.Contents() + if te.IsSymlink() { + bts, err := te.Contents() + if err != nil { + return "", "", err + } + fp = string(bts) + te, err = t.TreeEntry(fp) + if err != nil { + return "", "", err + } + } + bts, err := te.Contents() if err != nil { return "", "", err }