From 1b4104a928fd5c5f20668a1ef186713e568a8ea0 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sun, 8 Sep 2013 22:51:36 -0400 Subject: [PATCH] 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. --- asink/client.go | 6 ++++++ asink/watcher.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/asink/client.go b/asink/client.go index be180ba..9854acc 100644 --- a/asink/client.go +++ b/asink/client.go @@ -141,6 +141,12 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) { defer UnlockPath(event) if latestLocal != nil { 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() { diff --git a/asink/watcher.go b/asink/watcher.go index ab6cbdd..62641e7 100644 --- a/asink/watcher.go +++ b/asink/watcher.go @@ -29,7 +29,7 @@ func StartWatching(watchDir string, fileUpdates chan *asink.Event) { event := new(asink.Event) event.Path = path event.Type = asink.UPDATE - event.Timestamp = info.ModTime().UnixNano() + event.Timestamp = time.Now().UnixNano() fileUpdates <- event } return nil