Merge pull request #99 from arunmathew88/TailingStopBugFix
Tailing stop bug fix
This commit is contained in:
commit
46ed7f0315
|
@ -8,7 +8,7 @@ type FileChanges struct {
|
||||||
|
|
||||||
func NewFileChanges() *FileChanges {
|
func NewFileChanges() *FileChanges {
|
||||||
return &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() {
|
func (fc *FileChanges) NotifyModified() {
|
||||||
|
|
|
@ -75,7 +75,6 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
|
||||||
fw.Size = pos
|
fw.Size = pos
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer RemoveWatch(fw.Filename)
|
|
||||||
|
|
||||||
events := Events(fw.Filename)
|
events := Events(fw.Filename)
|
||||||
|
|
||||||
|
@ -88,9 +87,11 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
|
||||||
select {
|
select {
|
||||||
case evt, ok = <-events:
|
case evt, ok = <-events:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
RemoveWatch(fw.Filename)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-t.Dying():
|
case <-t.Dying():
|
||||||
|
RemoveWatch(fw.Filename)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +109,7 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
case evt.Op&fsnotify.Rename == fsnotify.Rename:
|
case evt.Op&fsnotify.Rename == fsnotify.Rename:
|
||||||
|
RemoveWatch(fw.Filename)
|
||||||
changes.NotifyDeleted()
|
changes.NotifyDeleted()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -115,6 +117,7 @@ func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChange
|
||||||
fi, err := os.Stat(fw.Filename)
|
fi, err := os.Stat(fw.Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
RemoveWatch(fw.Filename)
|
||||||
changes.NotifyDeleted()
|
changes.NotifyDeleted()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue