diff --git a/internal/httpserver/httpServer.go b/internal/httpserver/httpServer.go index 737822b..0d49f6b 100644 --- a/internal/httpserver/httpServer.go +++ b/internal/httpserver/httpServer.go @@ -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) } diff --git a/internal/loader/loader.go b/internal/loader/loader.go index 14de716..5dee50f 100644 --- a/internal/loader/loader.go +++ b/internal/loader/loader.go @@ -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) } diff --git a/internal/types/id.go b/internal/types/id.go index c33bc14..cc57033 100644 --- a/internal/types/id.go +++ b/internal/types/id.go @@ -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()