Skip to content

Commit

Permalink
Merge pull request hpcloud#99 from arunmathew88/TailingStopBugFix
Browse files Browse the repository at this point in the history
Tailing stop bug fix
  • Loading branch information
Nino Kodabande authored Feb 7, 2017
2 parents 915e5fe + 48cd000 commit 46ed7f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion watch/filechanges.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type FileChanges struct {

func NewFileChanges() *FileChanges {
return &FileChanges{
make(chan bool), make(chan bool), make(chan bool)}
make(chan bool, 1), make(chan bool, 1), make(chan bool, 1)}
}

func (fc *FileChanges) NotifyModified() {
Expand Down
5 changes: 4 additions & 1 deletion watch/inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
fw.Size = pos

go func() {
defer RemoveWatch(fw.Filename)

events := Events(fw.Filename)

Expand All @@ -88,9 +87,11 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
select {
case evt, ok = <-events:
if !ok {
RemoveWatch(fw.Filename)
return
}
case <-t.Dying():
RemoveWatch(fw.Filename)
return
}

Expand All @@ -108,13 +109,15 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
fallthrough

case evt.Op&fsnotify.Rename == fsnotify.Rename:
RemoveWatch(fw.Filename)
changes.NotifyDeleted()
return

case evt.Op&fsnotify.Write == fsnotify.Write:
fi, err := os.Stat(fw.Filename)
if err != nil {
if os.IsNotExist(err) {
RemoveWatch(fw.Filename)
changes.NotifyDeleted()
return
}
Expand Down

0 comments on commit 46ed7f0

Please sign in to comment.