This change fixes file truncation on Mac OS X (I have 10.11.6). The current code is broken there:
Vlads-MacBook-Air:tail vlad$ go test --test.run=TestReSeekInotify
2017/03/17 19:16:14 Stopping tail as file no longer exists: .test/reseek-inotify/test.txt
--- FAIL: TestReSeekInotify (0.20s)
tail_test.go:499: tail ended early; expecting more: [h311o w0r1d endofworld]
FAIL
exit status 1
FAIL github.com/hpcloud/tail 0.213s
The problems is that the file truncation operation apparently sends the Chmod event in Mac OS X, and the ChangeEvents function's Chmod case allows that event to fall through into the Rename case which removes the watch, preventing further updates.
This change discriminates between the case of non-existent file, which still falls through, and existing file, which causes the function to continue listening.
This change fixes file truncation on Mac OS X (I have 10.11.6). The current code is broken there:
The problems is that the file truncation operation apparently sends the
Chmod
event in Mac OS X, and theChangeEvents
function'sChmod
case allows that event to fall through into theRename
case which removes the watch, preventing further updates.This change discriminates between the case of non-existent file, which still falls through, and existing file, which causes the function to continue listening.