feat: clear cache after change
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/internal/operations"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
@ -12,6 +13,14 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func ClearCache(path string) {
|
||||
account, actualPath, err := operations.GetAccountAndActualPath(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
operations.ClearCache(account, actualPath)
|
||||
}
|
||||
|
||||
func containsByName(files []model.Obj, file model.Obj) bool {
|
||||
for _, f := range files {
|
||||
if f.GetName() == file.GetName() {
|
||||
|
@ -22,6 +22,11 @@ import (
|
||||
var filesCache = cache.NewMemCache(cache.WithShards[[]model.Obj](64))
|
||||
var filesG singleflight.Group[[]model.Obj]
|
||||
|
||||
func ClearCache(account driver.Driver, path string) {
|
||||
key := stdpath.Join(account.GetAccount().VirtualPath, path)
|
||||
filesCache.Del(key)
|
||||
}
|
||||
|
||||
// List files in storage, not contains virtual file
|
||||
func List(ctx context.Context, account driver.Driver, path string, refresh ...bool) ([]model.Obj, error) {
|
||||
path = utils.StandardizePath(path)
|
||||
|
Reference in New Issue
Block a user