summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-02-10 15:42:21 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-02-10 17:02:06 +0100
commite6feb9e0be52c542c354f737fca9863eccb7102c (patch)
tree02f5987aeff5803a0e62de120bfea2239a3fe143 /commands
parent5e4ffa0e892a0668ade6fe0c0b766881a55c7efd (diff)
downloadhugo-e6feb9e0be52c542c354f737fca9863eccb7102c.tar.gz
hugo-e6feb9e0be52c542c354f737fca9863eccb7102c.zip
commands: Move the CHMOD event filter up
To prevent ghost rebuilds (from VSCode and possibly others). Fixes #13373
Diffstat (limited to 'commands')
-rw-r--r--commands/hugobuilder.go30
1 files changed, 14 insertions, 16 deletions
diff --git a/commands/hugobuilder.go b/commands/hugobuilder.go
index 4c2d865c0..778d85ca9 100644
--- a/commands/hugobuilder.go
+++ b/commands/hugobuilder.go
@@ -663,7 +663,20 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
var n int
for _, ev := range evs {
keep := true
- if ev.Has(fsnotify.Create) || ev.Has(fsnotify.Write) {
+ // Write and rename operations are often followed by CHMOD.
+ // There may be valid use cases for rebuilding the site on CHMOD,
+ // but that will require more complex logic than this simple conditional.
+ // On OS X this seems to be related to Spotlight, see:
+ // https://github.com/go-fsnotify/fsnotify/issues/15
+ // A workaround is to put your site(s) on the Spotlight exception list,
+ // but that may be a little mysterious for most end users.
+ // So, for now, we skip reload on CHMOD.
+ // We do have to check for WRITE though. On slower laptops a Chmod
+ // could be aggregated with other important events, and we still want
+ // to rebuild on those
+ if ev.Op == fsnotify.Chmod {
+ keep = false
+ } else if ev.Has(fsnotify.Create) || ev.Has(fsnotify.Write) {
if _, err := os.Stat(ev.Name); err != nil {
keep = false
}
@@ -805,21 +818,6 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
continue
}
- // Write and rename operations are often followed by CHMOD.
- // There may be valid use cases for rebuilding the site on CHMOD,
- // but that will require more complex logic than this simple conditional.
- // On OS X this seems to be related to Spotlight, see:
- // https://github.com/go-fsnotify/fsnotify/issues/15
- // A workaround is to put your site(s) on the Spotlight exception list,
- // but that may be a little mysterious for most end users.
- // So, for now, we skip reload on CHMOD.
- // We do have to check for WRITE though. On slower laptops a Chmod
- // could be aggregated with other important events, and we still want
- // to rebuild on those
- if ev.Op&(fsnotify.Chmod|fsnotify.Write|fsnotify.Create) == fsnotify.Chmod {
- continue
- }
-
walkAdder := func(path string, f hugofs.FileMetaInfo) error {
if f.IsDir() {
c.r.logger.Println("adding created directory to watchlist", path)