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 bramp committed Dec 17, 2015
1 parent dfe1a3e commit 1ac07ea
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 @@ -506,6 +506,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 1ac07ea

Please sign in to comment.