Skip to content

Commit

Permalink
Re-add watch (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayrer committed Sep 21, 2017
1 parent 263b55e commit de2fec6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo: required
language: go
go: 1.6
go: 1.8

services:
- docker
Expand Down
13 changes: 10 additions & 3 deletions client/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func New(path string) (w *Watcher) {
return nil
}

printer.Logf("watching path`: %s", path)

w = &Watcher{
path: path,
}
Expand Down Expand Up @@ -66,7 +68,6 @@ func (w *Watcher) Init() error {
return nil
}

// Watch observes WRITE events, forwarding them to `Updated`
func (w *Watcher) Watch() {
done := make(chan bool)
go func() {
Expand All @@ -79,11 +80,17 @@ func (w *Watcher) Watch() {
event.Op&fsnotify.Chmod == fsnotify.Chmod {
err := w.UpdateBytes()
if err != nil {
printer.LogErrf("[dcdr] UpdateBytes error: %v", err)
printer.LogErrf("UpdateBytes error: %v", err)
}

// Rewatch the path
err = w.watcher.Add(w.path)
if err != nil {
printer.LogErrf("fsnotify Add error: %v", err)
}
}
case err := <-w.watcher.Errors:
printer.LogErrf("[dcdr] watch error: %v", err)
printer.LogErrf("watch error: %v", err)
}
w.mu.Unlock()
}
Expand Down

0 comments on commit de2fec6

Please sign in to comment.