fix(alias): Support forced refresh of file list (#6562)

This commit is contained in:
j2rong4cn
2024-06-16 16:59:10 +08:00
committed by GitHub
parent fcf2683112
commit 29fe49fb87
5 changed files with 27 additions and 24 deletions

View File

@ -24,7 +24,8 @@ func list(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error)
if storage != nil {
_objs, err = op.List(ctx, storage, actualPath, model.ListArgs{
ReqPath: path,
}, args.Refresh)
Refresh: args.Refresh,
})
if err != nil {
if !args.NoLog {
log.Errorf("fs/list: %+v", err)

View File

@ -13,6 +13,7 @@ import (
type ListArgs struct {
ReqPath string
S3ShowPlaceholder bool
Refresh bool
}
type LinkArgs struct {

View File

@ -100,14 +100,14 @@ func Key(storage driver.Driver, path string) string {
}
// List files in storage, not contains virtual file
func List(ctx context.Context, storage driver.Driver, path string, args model.ListArgs, refresh ...bool) ([]model.Obj, error) {
func List(ctx context.Context, storage driver.Driver, path string, args model.ListArgs) ([]model.Obj, error) {
if storage.Config().CheckStatus && storage.GetStorage().Status != WORK {
return nil, errors.Errorf("storage not init: %s", storage.GetStorage().Status)
}
path = utils.FixAndCleanPath(path)
log.Debugf("op.List %s", path)
key := Key(storage, path)
if !utils.IsBool(refresh...) {
if !args.Refresh {
if files, ok := listCache.Get(key); ok {
log.Debugf("use cache when list %s", path)
return files, nil