fix: wrong virtual file name

refactor/fs
Noah Hsu 2022-06-14 22:23:10 +08:00
parent b73dbee7e6
commit 097b516dc5
1 changed files with 5 additions and 4 deletions

View File

@ -148,19 +148,20 @@ func GetAccountVirtualFilesByPath(prefix string) []driver.FileInfo {
prefix = utils.StandardizationPath(prefix) prefix = utils.StandardizationPath(prefix)
set := make(map[string]interface{}) set := make(map[string]interface{})
for _, v := range accounts { for _, v := range accounts {
// TODO should save a balanced account
// balance account // balance account
if utils.IsBalance(v.GetAccount().VirtualPath) { if utils.IsBalance(v.GetAccount().VirtualPath) {
continue continue
} }
full := v.GetAccount().VirtualPath virtualPath := v.GetAccount().VirtualPath
if len(full) <= len(prefix) { if len(virtualPath) <= len(prefix) {
continue continue
} }
// not prefixed with `prefix` // not prefixed with `prefix`
if !strings.HasPrefix(full, prefix+"/") && prefix != "/" { if !strings.HasPrefix(virtualPath, prefix+"/") && prefix != "/" {
continue continue
} }
name := strings.Split(strings.TrimPrefix(full, prefix), "/")[0] name := strings.Split(strings.TrimPrefix(virtualPath, prefix), "/")[1]
if _, ok := set[name]; ok { if _, ok := set[name]; ok {
continue continue
} }