mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Fix deletion of orphaned sections
Avoid deleting inside the recursive walk. Fixes #6920
This commit is contained in:
parent
24afe2b822
commit
a70bbd0696
1 changed files with 6 additions and 1 deletions
|
@ -596,6 +596,7 @@ func (m *contentMap) deleteBundleMatching(matches func(b *contentNode) bool) {
|
||||||
|
|
||||||
// Deletes any empty root section that's not backed by a content file.
|
// Deletes any empty root section that's not backed by a content file.
|
||||||
func (m *contentMap) deleteOrphanSections() {
|
func (m *contentMap) deleteOrphanSections() {
|
||||||
|
var sectionsToDelete []string
|
||||||
|
|
||||||
m.sections.Walk(func(s string, v interface{}) bool {
|
m.sections.Walk(func(s string, v interface{}) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
|
@ -612,11 +613,15 @@ func (m *contentMap) deleteOrphanSections() {
|
||||||
prefixBundle := s + cmBranchSeparator
|
prefixBundle := s + cmBranchSeparator
|
||||||
|
|
||||||
if !(m.sections.hasPrefix(s+"/") || m.pages.hasPrefix(prefixBundle) || m.resources.hasPrefix(prefixBundle)) {
|
if !(m.sections.hasPrefix(s+"/") || m.pages.hasPrefix(prefixBundle) || m.resources.hasPrefix(prefixBundle)) {
|
||||||
m.sections.Delete(s)
|
sectionsToDelete = append(sectionsToDelete, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for _, s := range sectionsToDelete {
|
||||||
|
m.sections.Delete(s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *contentMap) deletePage(s string) {
|
func (m *contentMap) deletePage(s string) {
|
||||||
|
|
Loading…
Reference in a new issue