createDir cache fix
This commit is contained in:
parent
c20748aef1
commit
65739c9307
@ -34,3 +34,20 @@ func getPathFromId(id string) string {
|
|||||||
func getFilenameFromID(id string) string {
|
func getFilenameFromID(id string) string {
|
||||||
return filepath.Base(id)
|
return filepath.Base(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func invalidateCacheForDir(ctx context.Context, path string) error {
|
||||||
|
loader, ok := ctx.Value("loader").(map[string]*dataloader.Loader)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("Failed to get loader from context")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("Invalidate cache for dir: ", path)
|
||||||
|
|
||||||
|
// FIXME: only clear required ids
|
||||||
|
loader["getFile"].ClearAll()
|
||||||
|
loader["listObjects"].ClearAll()
|
||||||
|
loader["getFiles"].ClearAll()
|
||||||
|
loader["getDirs"].ClearAll()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -123,6 +123,10 @@ func createDirectory(ctx context.Context, path string) (*Directory, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalidate cache
|
||||||
|
// TODO: check error
|
||||||
|
invalidateCacheForDir(ctx, info.Key)
|
||||||
|
|
||||||
return &Directory{
|
return &Directory{
|
||||||
ID: info.Key,
|
ID: info.Key,
|
||||||
}, nil
|
}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user