From af05f05ce1cb79403da35f0baae88d4d42000a8a Mon Sep 17 00:00:00 2001 From: Samuel N Cui Date: Mon, 18 Mar 2024 21:39:12 +0800 Subject: [PATCH] feat: get abs before get mount point --- fs.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs.go b/fs.go index 53eecf9..b9fbc26 100644 --- a/fs.go +++ b/fs.go @@ -2,6 +2,7 @@ package acp import ( "fmt" + "path/filepath" "strings" mapset "github.com/deckarep/golang-set/v2" @@ -33,6 +34,11 @@ func getMountpointCache() (func(string) string, error) { mps := mountPoints.ToSlice() return Cache(func(path string) string { + path, err := filepath.Abs(path) + if err != nil { + panic(fmt.Errorf("get abs from file path failed, path= '%s', %w", path, err)) + } + for _, mp := range mps { if strings.HasPrefix(path, mp) { return mp