Skip to content

Commit

Permalink
fix: hide objs if only virtual files
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 17, 2022
1 parent d329df7 commit bec3a32
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions internal/fs/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,43 @@ import (
func list(ctx context.Context, path string, refresh ...bool) ([]model.Obj, error) {
meta := ctx.Value("meta").(*model.Meta)
user := ctx.Value("user").(*model.User)
var objs []model.Obj
storage, actualPath, err := op.GetStorageAndActualPath(path)
virtualFiles := op.GetStorageVirtualFilesByPath(path)
if err != nil {
if len(virtualFiles) != 0 {
return virtualFiles, nil
if len(virtualFiles) == 0 {
return nil, errors.WithMessage(err, "failed get storage")
}
return nil, errors.WithMessage(err, "failed get storage")
}
objs, err := op.List(ctx, storage, actualPath, model.ListArgs{
ReqPath: path,
}, refresh...)
if err != nil {
log.Errorf("%+v", err)
if len(virtualFiles) != 0 {
return virtualFiles, nil
} else {
objs, err = op.List(ctx, storage, actualPath, model.ListArgs{
ReqPath: path,
}, refresh...)
if err != nil {
log.Errorf("%+v", err)
if len(virtualFiles) == 0 {
return nil, errors.WithMessage(err, "failed get objs")
}
}
return nil, errors.WithMessage(err, "failed get objs")
}
for _, storageFile := range virtualFiles {
if !containsByName(objs, storageFile) {
objs = append(objs, storageFile)
if objs == nil {
objs = virtualFiles
} else {
for _, storageFile := range virtualFiles {
if !containsByName(objs, storageFile) {
objs = append(objs, storageFile)
}
}
}
if whetherHide(user, meta, path) {
objs = hide(objs, meta)
}
// sort objs
if storage.Config().LocalSort {
model.SortFiles(objs, storage.GetStorage().OrderBy, storage.GetStorage().OrderDirection)
if storage != nil {
if storage.Config().LocalSort {
model.SortFiles(objs, storage.GetStorage().OrderBy, storage.GetStorage().OrderDirection)
}
model.ExtractFolder(objs, storage.GetStorage().ExtractFolder)
}
model.ExtractFolder(objs, storage.GetStorage().ExtractFolder)
return objs, nil
}

Expand Down

0 comments on commit bec3a32

Please sign in to comment.