fixed cache invalidation

This commit is contained in:
Djeeberjr 2021-10-14 23:46:48 +02:00
parent 439e5473b6
commit 8c6f59a6b4
3 changed files with 9 additions and 8 deletions

View File

@ -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)
} }

View File

@ -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)
} }

View File

@ -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()