1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00

hugolib, commands: Improve live-reload on directory structure changes

This issue is more visible now that we support nested sections.

This commit makes operations like pasting new content folders or deleting content folders during server watch just work.

Fixes #3570
This commit is contained in:
Bjørn Erik Pedersen
2017-06-08 20:00:05 +02:00
parent b39689393c
commit fe901b8119
4 changed files with 39 additions and 8 deletions

View File

@@ -137,6 +137,18 @@ func (c *PageCollections) addPage(page *Page) {
c.rawAllPages = append(c.rawAllPages, page)
}
// When we get a REMOVE event we're not always getting all the individual files,
// so we need to remove all below a given path.
func (c *PageCollections) removePageByPathPrefix(path string) {
for {
i := c.rawAllPages.FindPagePosByFilePathPrefix(path)
if i == -1 {
break
}
c.rawAllPages = append(c.rawAllPages[:i], c.rawAllPages[i+1:]...)
}
}
func (c *PageCollections) removePageByPath(path string) {
if i := c.rawAllPages.FindPagePosByFilePath(path); i >= 0 {
c.rawAllPages = append(c.rawAllPages[:i], c.rawAllPages[i+1:]...)