mirror of https://github.com/Xhofe/alist
fix: cache is modified while sorting (close #2340)
parent
3fbdf6f022
commit
4dcaa24758
|
@ -24,7 +24,7 @@ func list(ctx context.Context, path string, refresh ...bool) ([]model.Obj, error
|
|||
return nil, errors.WithMessage(err, "failed get storage")
|
||||
}
|
||||
} else {
|
||||
objs, err = op.List(ctx, storage, actualPath, model.ListArgs{
|
||||
_objs, err := op.List(ctx, storage, actualPath, model.ListArgs{
|
||||
ReqPath: path,
|
||||
}, refresh...)
|
||||
if err != nil {
|
||||
|
@ -33,6 +33,8 @@ func list(ctx context.Context, path string, refresh ...bool) ([]model.Obj, error
|
|||
return nil, errors.WithMessage(err, "failed get objs")
|
||||
}
|
||||
}
|
||||
objs = make([]model.Obj, len(_objs))
|
||||
copy(objs, _objs)
|
||||
}
|
||||
if objs == nil {
|
||||
objs = virtualFiles
|
||||
|
|
|
@ -60,8 +60,10 @@ func List(ctx context.Context, storage driver.Driver, path string, args model.Li
|
|||
}
|
||||
if !storage.Config().NoCache {
|
||||
if len(files) > 0 {
|
||||
log.Debugf("set cache: %s => %+v", key, files)
|
||||
listCache.Set(key, files, cache.WithEx[[]model.Obj](time.Minute*time.Duration(storage.GetStorage().CacheExpiration)))
|
||||
} else {
|
||||
log.Debugf("del cache: %s", key)
|
||||
listCache.Del(key)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue