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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
mapset "github.com/deckarep/golang-set/v2"
|
mapset "github.com/deckarep/golang-set/v2"
|
||||||
@@ -33,6 +34,11 @@ func getMountpointCache() (func(string) string, error) {
|
|||||||
|
|
||||||
mps := mountPoints.ToSlice()
|
mps := mountPoints.ToSlice()
|
||||||
return Cache(func(path string) string {
|
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 {
|
for _, mp := range mps {
|
||||||
if strings.HasPrefix(path, mp) {
|
if strings.HasPrefix(path, mp) {
|
||||||
return mp
|
return mp
|
||||||
|
|||||||
Reference in New Issue
Block a user