Be less aggressive with CHMOD filesystem events
authorPedro Melo <melo@simplicidade.org>
Tue, 26 Jul 2016 20:18:15 +0000 (21:18 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 26 Jul 2016 20:18:15 +0000 (22:18 +0200)
On 4679fbee41d3, rebuild was disabled on
CHMOD filesystem events, but the code is overly aggressive.

In some situations, specially with older Mac's (using a Late 2008
Macbook), the events we receive might be aggregated. On my
particular laptop, I get this events:

    INFO: 2016/07/26 18:08:51 hugo.go:737: Received System Events: ["<path>": WRITE|CHMOD]

These events are ignored because the code only checks for Chmod. This
commit fixes this by checking that the event is also not a Write or Create.

Related to #1587.

commands/hugo.go

index d1b82d80460ddbc4254440c745e74940020c2fec..f05b3da65f3e0dd25d4c9f2865c80b5fd3b0dceb 100644 (file)
@@ -775,7 +775,10 @@ func NewWatcher(port int) error {
                                        // 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 {
+                                       // 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
                                        }