mirror of
https://github.com/HChaZZY/alist.git
synced 2025-12-06 11:03:49 +08:00
fix(fs): remove old target object from cache before updating (#8352)
This commit is contained in:
@@ -3,6 +3,7 @@ package op
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
stdpath "path"
|
stdpath "path"
|
||||||
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Xhofe/go-cache"
|
"github.com/Xhofe/go-cache"
|
||||||
@@ -25,6 +26,12 @@ func updateCacheObj(storage driver.Driver, path string, oldObj model.Obj, newObj
|
|||||||
key := Key(storage, path)
|
key := Key(storage, path)
|
||||||
objs, ok := listCache.Get(key)
|
objs, ok := listCache.Get(key)
|
||||||
if ok {
|
if ok {
|
||||||
|
for i, obj := range objs {
|
||||||
|
if obj.GetName() == newObj.GetName() {
|
||||||
|
objs = slices.Delete(objs, i, i+1)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
for i, obj := range objs {
|
for i, obj := range objs {
|
||||||
if obj.GetName() == oldObj.GetName() {
|
if obj.GetName() == oldObj.GetName() {
|
||||||
objs[i] = newObj
|
objs[i] = newObj
|
||||||
|
|||||||
Reference in New Issue
Block a user