Skip to content

Commit

Permalink
Do not rebuild on extra Spotlight filesystem events
Browse files Browse the repository at this point in the history
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.

This small commit will be a 100% improvement for most OS X-users.

Fixes gohugoio#1587
  • Loading branch information
bep authored and tychoish committed Aug 13, 2017
1 parent 161dcd0 commit 81f7bee
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,18 @@ func NewWatcher(port int) error {
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.
if ev.Op&fsnotify.Chmod == fsnotify.Chmod {
continue
}

isstatic := strings.HasPrefix(ev.Name, helpers.GetStaticDirPath()) || (len(helpers.GetThemesDirPath()) > 0 && strings.HasPrefix(ev.Name, helpers.GetThemesDirPath()))
staticChanged = staticChanged || isstatic
dynamicChanged = dynamicChanged || !isstatic
Expand Down

0 comments on commit 81f7bee

Please sign in to comment.