commit 556b22ca94a15b427af591a3aa38b8a9c9ff1661
parent 2bddc363f20210ab019eec29d8ba4104d147e9b7
Author: lash <dev@holbrook.no>
Date: Thu, 5 Sep 2024 23:55:14 +0100
Handle cache edge case on first invocation of engine first func
Diffstat:
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/cache/cache.go b/cache/cache.go
@@ -160,6 +160,9 @@ func (ca *Cache) Pop() error {
logg.Debugf("Cache free", "frame", l, "key", k, "size", sz)
}
ca.Cache = ca.Cache[:l]
+ if l == 0 {
+ ca.Push()
+ }
//ca.resetCurrent()
return nil
}
diff --git a/engine/db.go b/engine/db.go
@@ -301,6 +301,8 @@ func(en *DefaultEngine) runFirst(ctx context.Context) (bool, error) {
}
en.st.ResetFlag(state.FLAG_TERMINATE)
en.st.ResetFlag(state.FLAG_DIRTY)
+ en.st.Up()
+ en.ca.Pop()
logg.DebugCtxf(ctx, "end pre-VM check")
return r, err
}
diff --git a/resource/db.go b/resource/db.go
@@ -84,7 +84,7 @@ func(g *DbResource) sfn(ctx context.Context, sym string) (string, error) {
//
// By default bound to GetTemplate. Can be replaced with WithTemplateGetter.
func(g *DbResource) DbGetTemplate(ctx context.Context, sym string) (string, error) {
- if g.typs & db.DATATYPE_TEMPLATE == 0{
+ if g.typs & db.DATATYPE_TEMPLATE == 0 {
return "", errors.New("not a template getter")
}
g.db.SetPrefix(db.DATATYPE_TEMPLATE)