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
|
||||
}
|
||||
|
||||
// Invalidate cache
|
||||
ctx.Value("loader").(*loader.Loader).InvalidateCacheForFile(ctx, *id)
|
||||
loader := ctx.Value("loader").(*loader.Loader)
|
||||
loader.InvalidateCacheForFile(ctx, *id)
|
||||
loader.InvalidateCacheForDir(ctx, *id.Parent())
|
||||
|
||||
rw.WriteHeader(http.StatusCreated)
|
||||
}
|
||||
|
@ -146,17 +146,17 @@ func (l *Loader) GetFilesRecursive(ctx context.Context, path types.ID) ([]types.
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
l.listObjectsLoader.Clear(ctx, id)
|
||||
l.listObjectsRecursiveLoader.Clear(ctx, parent)
|
||||
l.statObjectLoader.Clear(ctx, id)
|
||||
l.listObjectsLoader.Clear(ctx, id).Clear(ctx, parent)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
l.listBucketsLoader.Clear(ctx, path).Clear(ctx, parent)
|
||||
l.listObjectsLoader.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{
|
||||
Bucket: i.Bucket,
|
||||
Key: filepath.Dir(i.Key),
|
||||
Key: filepath.Dir(i.Key) + "/",
|
||||
}
|
||||
|
||||
parent.Normalize()
|
||||
|
Loading…
Reference in New Issue
Block a user