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