mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-02 16:40:07 +03: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:
parent
b39689393c
commit
fe901b8119
4 changed files with 39 additions and 8 deletions
|
@ -829,6 +829,11 @@ func (c *commandeer) newWatcher(port int) error {
|
|||
if err := watcher.Add(path); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if !c.isStatic(path) {
|
||||
// Hugo's rebuilding logic is entirely file based. When you drop a new folder into
|
||||
// /content on OSX, the above logic will handle future watching of those files,
|
||||
// but the initial CREATE is lost.
|
||||
dynamicEvents = append(dynamicEvents, fsnotify.Event{Name: path, Op: fsnotify.Create})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -841,9 +846,7 @@ func (c *commandeer) newWatcher(port int) error {
|
|||
}
|
||||
}
|
||||
|
||||
isstatic := strings.HasPrefix(ev.Name, c.PathSpec().GetStaticDirPath()) || (len(c.PathSpec().GetThemesDirPath()) > 0 && strings.HasPrefix(ev.Name, c.PathSpec().GetThemesDirPath()))
|
||||
|
||||
if isstatic {
|
||||
if c.isStatic(ev.Name) {
|
||||
staticEvents = append(staticEvents, ev)
|
||||
} else {
|
||||
dynamicEvents = append(dynamicEvents, ev)
|
||||
|
@ -999,6 +1002,10 @@ func (c *commandeer) newWatcher(port int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *commandeer) isStatic(path string) bool {
|
||||
return strings.HasPrefix(path, c.PathSpec().GetStaticDirPath()) || (len(c.PathSpec().GetThemesDirPath()) > 0 && strings.HasPrefix(path, c.PathSpec().GetThemesDirPath()))
|
||||
}
|
||||
|
||||
// isThemeVsHugoVersionMismatch returns whether the current Hugo version is
|
||||
// less than the theme's min_version.
|
||||
func (c *commandeer) isThemeVsHugoVersionMismatch() (mismatch bool, requiredMinVersion string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue