mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add missing read lock in getNodes
This commit is contained in:
parent
a8fad86671
commit
97c57fe37a
2 changed files with 5 additions and 4 deletions
|
@ -42,7 +42,7 @@ type HugoSites struct {
|
||||||
|
|
||||||
// Maps internalID to a set of nodes.
|
// Maps internalID to a set of nodes.
|
||||||
nodeMap map[string]Nodes
|
nodeMap map[string]Nodes
|
||||||
nodeMapMu sync.Mutex
|
nodeMapMu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHugoSites creates a new collection of sites given the input sites, building
|
// 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 {
|
func (h *HugoSites) getNodes(nodeID string) Nodes {
|
||||||
// At this point it is read only, so no need to lock.
|
|
||||||
if nodeID != "" {
|
if nodeID != "" {
|
||||||
if nodes, ok := h.nodeMap[nodeID]; ok {
|
h.nodeMapMu.RLock()
|
||||||
|
nodes, ok := h.nodeMap[nodeID]
|
||||||
|
h.nodeMapMu.RUnlock()
|
||||||
|
if ok {
|
||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,7 +288,6 @@ func (n *Node) IsTranslated() bool {
|
||||||
func (n *Node) initTranslations() {
|
func (n *Node) initTranslations() {
|
||||||
n.translationsInit.Do(func() {
|
n.translationsInit.Do(func() {
|
||||||
n.translations = n.Site.owner.getNodes(n.nodeID)
|
n.translations = n.Site.owner.getNodes(n.nodeID)
|
||||||
//sort.Sort(n.translations)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue