From 281093c834c7db0ce1a9440690bbfc8cb9b98215 Mon Sep 17 00:00:00 2001 From: rsteube Date: Thu, 10 Oct 2024 21:40:58 +0200 Subject: [PATCH] actionPath: fix symlinks --- internalActions.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/internalActions.go b/internalActions.go index 03a38ff1..054f10d9 100644 --- a/internalActions.go +++ b/internalActions.go @@ -47,19 +47,23 @@ func actionPath(fileSuffixes []string, dirOnly bool) Action { continue } - resolvedFile, err := file.Info() + info, err := file.Info() if err != nil { return ActionMessage(err.Error()) } - if resolved, err := filepath.EvalSymlinks(actualFolder + file.Name()); err == nil { - if stat, err := os.Stat(resolved); err == nil { - resolvedFile = stat + symlinkedDir := false + if evaluatedPath, err := filepath.EvalSymlinks(actualFolder + "/" + file.Name()); err == nil { + if evaluatedInfo, err := os.Stat(evaluatedPath); err == nil { + symlinkedDir = evaluatedInfo.IsDir() } } - if resolvedFile.IsDir() { + switch { + case info.IsDir(): vals = append(vals, displayFolder+file.Name()+"/", style.ForPath(filepath.Clean(actualFolder+"/"+file.Name()+"/"), c)) - } else if !dirOnly { + case symlinkedDir: + vals = append(vals, displayFolder+file.Name()+"/", style.ForPath(filepath.Clean(actualFolder+"/"+file.Name()), c)) // TODO colorist not returning the symlink color + case !dirOnly: if len(fileSuffixes) == 0 { fileSuffixes = []string{""} }