fix: #686 - concurrent map read and write

This commit is contained in:
jamesread 2025-11-04 23:03:45 +00:00
parent 2a6d9e4f68
commit 294e33d110
2 changed files with 10 additions and 1 deletions

View File

@ -60,10 +60,16 @@ func GetAll() *variableBase {
}
func GetEntities() entitiesByClass {
rwmutex.RLock()
defer rwmutex.RUnlock()
return contents.Entities
}
func GetEntityInstances(entityName string) entityInstancesByKey {
rwmutex.RLock()
defer rwmutex.RUnlock()
if entities, ok := contents.Entities[entityName]; ok {
return entities
}

View File

@ -91,7 +91,7 @@ func ParseTemplateWithArgs(source string, ent *Entity, args map[string]string) s
}
templateVariables := &variableBase{
OliveTin: contents.OliveTin,
OliveTin: GetAll().OliveTin,
Arguments: args,
CurrentEntity: entdata,
}
@ -126,5 +126,8 @@ func ParseTemplateBoolWith(source string, ent *Entity) bool {
}
func ClearEntities(entityType string) {
rwmutex.Lock()
defer rwmutex.Unlock()
delete(contents.Entities, entityType)
}