fixed cache invalidation
This commit is contained in:
parent
439e5473b6
commit
8c6f59a6b4
@ -195,8 +195,9 @@ func httpPostFile(ctx context.Context, rw http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate cache
|
loader := ctx.Value("loader").(*loader.Loader)
|
||||||
ctx.Value("loader").(*loader.Loader).InvalidateCacheForFile(ctx, *id)
|
loader.InvalidateCacheForFile(ctx, *id)
|
||||||
|
loader.InvalidateCacheForDir(ctx, *id.Parent())
|
||||||
|
|
||||||
rw.WriteHeader(http.StatusCreated)
|
rw.WriteHeader(http.StatusCreated)
|
||||||
}
|
}
|
||||||
|
@ -149,14 +149,14 @@ func (l *Loader) InvalidateCacheForFile(ctx context.Context, id types.ID) {
|
|||||||
log.Debug("Clear cache for file: ", id.String())
|
log.Debug("Clear cache for file: ", id.String())
|
||||||
parent := id.Parent()
|
parent := id.Parent()
|
||||||
|
|
||||||
l.listObjectsLoader.Clear(ctx, id)
|
l.statObjectLoader.Clear(ctx, id)
|
||||||
l.listObjectsRecursiveLoader.Clear(ctx, parent)
|
l.listObjectsLoader.Clear(ctx, id).Clear(ctx, parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Loader) InvalidateCacheForDir(ctx context.Context, path types.ID) {
|
func (l *Loader) InvalidateCacheForDir(ctx context.Context, path types.ID) {
|
||||||
log.Debug("Clear cache for dir: ", path.String())
|
log.Debug("Clear cache for dir: ", path.String())
|
||||||
parent := helper.GetParentDir(path)
|
parent := helper.GetParentDir(path)
|
||||||
|
|
||||||
l.listBucketsLoader.Clear(ctx, path).Clear(ctx, parent)
|
l.listObjectsLoader.Clear(ctx, path).Clear(ctx, parent)
|
||||||
l.listObjectsRecursiveLoader.Clear(ctx, path).Clear(ctx, parent)
|
l.listObjectsRecursiveLoader.Clear(ctx, path).Clear(ctx, parent)
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (i ID) Parent() *ID {
|
|||||||
|
|
||||||
parent := &ID{
|
parent := &ID{
|
||||||
Bucket: i.Bucket,
|
Bucket: i.Bucket,
|
||||||
Key: filepath.Dir(i.Key),
|
Key: filepath.Dir(i.Key) + "/",
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.Normalize()
|
parent.Normalize()
|
||||||
|
Loading…
Reference in New Issue
Block a user