Add configFile(s) back to the watch list after REMOVE event
authorAnthony Fok <foka@debian.org>
Thu, 16 Aug 2018 02:51:27 +0000 (20:51 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 16 Aug 2018 14:11:57 +0000 (16:11 +0200)
Fixes #4701

commands/hugo.go

index fc8dced7475620769fbc4760b35ba7362591dab7..a97c282946f98152a4bfd994ab1de2628619d921 100644 (file)
@@ -705,6 +705,18 @@ func (c *commandeer) newWatcher(dirList ...string) (*watcher.Batcher, error) {
                                                if ev.Op&fsnotify.Chmod == fsnotify.Chmod {
                                                        continue
                                                }
+                                               if ev.Op&fsnotify.Remove == fsnotify.Remove {
+                                                       for _, configFile := range c.configFiles {
+                                                               counter := 0
+                                                               for watcher.Add(configFile) != nil {
+                                                                       counter++
+                                                                       if counter >= 100 {
+                                                                               break
+                                                                       }
+                                                                       time.Sleep(100 * time.Millisecond)
+                                                               }
+                                                       }
+                                               }
                                                // Config file changed. Need full rebuild.
                                                c.fullRebuild()
                                                break