Don't ever use UNIX file modification time for event modification time
Doing so can cause inconsistency and cause events to get dropped that shouldn't. Also add warning to local event side if an event is reported by the watcher that is not more recent than the event which was previously the latest local event.
This commit is contained in:
parent
d7cd6f348c
commit
1b4104a928
@ -141,6 +141,12 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
|
|||||||
defer UnlockPath(event)
|
defer UnlockPath(event)
|
||||||
if latestLocal != nil {
|
if latestLocal != nil {
|
||||||
event.Predecessor = latestLocal.Hash
|
event.Predecessor = latestLocal.Hash
|
||||||
|
|
||||||
|
if event.Timestamp < latestLocal.Timestamp {
|
||||||
|
fmt.Printf("trying to send event older than latestLocal:\n")
|
||||||
|
fmt.Printf("OLD %+v\n", latestLocal)
|
||||||
|
fmt.Printf("NEW %+v\n", event)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.IsUpdate() {
|
if event.IsUpdate() {
|
||||||
|
@ -29,7 +29,7 @@ func StartWatching(watchDir string, fileUpdates chan *asink.Event) {
|
|||||||
event := new(asink.Event)
|
event := new(asink.Event)
|
||||||
event.Path = path
|
event.Path = path
|
||||||
event.Type = asink.UPDATE
|
event.Type = asink.UPDATE
|
||||||
event.Timestamp = info.ModTime().UnixNano()
|
event.Timestamp = time.Now().UnixNano()
|
||||||
fileUpdates <- event
|
fileUpdates <- event
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user