fix: empty storage virtual file

pull/1604/head
Noah Hsu 2022-07-27 20:57:12 +08:00
parent 53fd09814a
commit 212dbb277e
1 changed files with 4 additions and 4 deletions

View File

@ -185,8 +185,8 @@ func GetStorageVirtualFilesByPath(prefix string) []model.Obj {
return storages[i].GetStorage().Index < storages[j].GetStorage().Index return storages[i].GetStorage().Index < storages[j].GetStorage().Index
}) })
prefix = utils.StandardizePath(prefix) prefix = utils.StandardizePath(prefix)
if prefix == "/" { if prefix != "/" {
prefix = "" prefix += "/"
} }
set := make(map[string]interface{}) set := make(map[string]interface{})
for _, v := range storages { for _, v := range storages {
@ -200,10 +200,10 @@ func GetStorageVirtualFilesByPath(prefix string) []model.Obj {
continue continue
} }
// not prefixed with `prefix` // not prefixed with `prefix`
if !strings.HasPrefix(virtualPath, prefix+"/") { if !strings.HasPrefix(virtualPath, prefix) {
continue continue
} }
name := strings.Split(strings.TrimPrefix(virtualPath, prefix), "/")[1] name := strings.Split(strings.TrimPrefix(virtualPath, prefix), "/")[0]
if _, ok := set[name]; ok { if _, ok := set[name]; ok {
continue continue
} }