diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 36b797e7e..c0e077bd1 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -42,7 +42,7 @@ type HugoSites struct { // Maps internalID to a set of nodes. nodeMap map[string]Nodes - nodeMapMu sync.Mutex + nodeMapMu sync.RWMutex } // NewHugoSites creates a new collection of sites given the input sites, building @@ -108,9 +108,11 @@ func (h *HugoSites) addNode(nodeID string, node *Node) { } func (h *HugoSites) getNodes(nodeID string) Nodes { - // At this point it is read only, so no need to lock. if nodeID != "" { - if nodes, ok := h.nodeMap[nodeID]; ok { + h.nodeMapMu.RLock() + nodes, ok := h.nodeMap[nodeID] + h.nodeMapMu.RUnlock() + if ok { return nodes } } diff --git a/hugolib/node.go b/hugolib/node.go index 3b3d40394..566fd4799 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -288,7 +288,6 @@ func (n *Node) IsTranslated() bool { func (n *Node) initTranslations() { n.translationsInit.Do(func() { n.translations = n.Site.owner.getNodes(n.nodeID) - //sort.Sort(n.translations) }) }