From 9daeaf75626587fde53c1f8c94a056da2478f373 Mon Sep 17 00:00:00 2001 From: Xhofe Date: Fri, 1 Apr 2022 09:40:08 +0800 Subject: [PATCH] fix: virtual path, support mount to root path --- model/account.go | 6 ++++++ server/common/common.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/model/account.go b/model/account.go index ffa66a47..e14be95a 100644 --- a/model/account.go +++ b/model/account.go @@ -207,6 +207,9 @@ func GetAccountsByPath(path string) []Account { if bIndex != -1 { name = name[:bIndex] } + if name == "/" { + name = "" + } // 不是这个账号 if path != name && !strings.HasPrefix(path, name+"/") { continue @@ -253,6 +256,9 @@ func GetAccountFilesByPath(prefix string) []File { continue } full := utils.ParsePath(v.Name) + if len(full) <= len(prefix) { + continue + } // 不是以prefix为前缀 if !strings.HasPrefix(full, prefix+"/") && prefix != "/" { continue diff --git a/server/common/common.go b/server/common/common.go index e829a9ae..cbebf57c 100644 --- a/server/common/common.go +++ b/server/common/common.go @@ -38,6 +38,9 @@ func ParsePath(rawPath string) (*model.Account, string, base.Driver, error) { if bIndex != -1 { name = name[:bIndex] } + if name == "/" { + name = "" + } return &account, strings.TrimPrefix(rawPath, name), driver, nil }