Commits

Julian Brost  committed 95698f0

Lock the theme object while something is accessing the cache map.

  • Participants
  • Parent commits 574508d

Comments (0)

Files changed (1)

 
 import (
 	"io/ioutil"
+	"path"
 	"strings"
-	"path"
+	"sync"
 )
 
 type Theme struct {
 	path  string
 	cache map[string]string
+	lock  sync.RWMutex
 }
 
 func NewTheme(path string) (*Theme, error) {
 }
 
 func (theme *Theme) GetTemplate(name string) (string, error) {
+	theme.lock.RLock()
 	template, found := theme.cache[name]
+	theme.lock.RUnlock()
 	if found {
 		return template, nil
 	}
 		return "", err
 	}
 	template = string(rawTemplate)
+	theme.lock.Lock()
 	theme.cache[name] = template
+	theme.lock.Unlock()
 	return template, nil
 }