Merge pull request #100 from bahlo/cleanup-error
Return error on tail.Cleanup
This commit is contained in:
commit
33107f39d5
|
@ -83,21 +83,21 @@ func watch(winfo *watchInfo) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveWatch signals the run goroutine to remove the watch for the input filename
|
// RemoveWatch signals the run goroutine to remove the watch for the input filename
|
||||||
func RemoveWatch(fname string) {
|
func RemoveWatch(fname string) error {
|
||||||
remove(&watchInfo{
|
return remove(&watchInfo{
|
||||||
fname: fname,
|
fname: fname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveWatch create signals the run goroutine to remove the watch for the input filename
|
// RemoveWatch create signals the run goroutine to remove the watch for the input filename
|
||||||
func RemoveWatchCreate(fname string) {
|
func RemoveWatchCreate(fname string) error {
|
||||||
remove(&watchInfo{
|
return remove(&watchInfo{
|
||||||
op: fsnotify.Create,
|
op: fsnotify.Create,
|
||||||
fname: fname,
|
fname: fname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func remove(winfo *watchInfo) {
|
func remove(winfo *watchInfo) error {
|
||||||
// start running the shared InotifyTracker if not already running
|
// start running the shared InotifyTracker if not already running
|
||||||
once.Do(goRun)
|
once.Do(goRun)
|
||||||
|
|
||||||
|
@ -126,9 +126,10 @@ func remove(winfo *watchInfo) {
|
||||||
// synchronously for the kernel to acknowledge the removal of the watch
|
// synchronously for the kernel to acknowledge the removal of the watch
|
||||||
// for this file, which causes us to deadlock if we still held the lock.
|
// for this file, which causes us to deadlock if we still held the lock.
|
||||||
if watchNum == 0 {
|
if watchNum == 0 {
|
||||||
shared.watcher.Remove(fname)
|
return shared.watcher.Remove(fname)
|
||||||
}
|
}
|
||||||
shared.remove <- winfo
|
shared.remove <- winfo
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Events returns a channel to which FileEvents corresponding to the input filename
|
// Events returns a channel to which FileEvents corresponding to the input filename
|
||||||
|
@ -142,8 +143,8 @@ func Events(fname string) <-chan fsnotify.Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup removes the watch for the input filename if necessary.
|
// Cleanup removes the watch for the input filename if necessary.
|
||||||
func Cleanup(fname string) {
|
func Cleanup(fname string) error {
|
||||||
RemoveWatch(fname)
|
return RemoveWatch(fname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// watchFlags calls fsnotify.WatchFlags for the input filename and flags, creating
|
// watchFlags calls fsnotify.WatchFlags for the input filename and flags, creating
|
||||||
|
|
Loading…
Reference in New Issue