mirror of
https://github.com/samuelncui/acp.git
synced 2025-12-23 05:05:15 +00:00
feat: get abs before get mount point
This commit is contained in:
6
fs.go
6
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
|
||||
|
||||
Reference in New Issue
Block a user