From 51626a137161bb0dc7d01908013c6797fb82e1cb Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Wed, 17 Sep 2014 17:34:03 +0200 Subject: [PATCH] Do nort send notifications if nothing changed. --- cmd/mtredisalize/changetracker.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/mtredisalize/changetracker.go b/cmd/mtredisalize/changetracker.go index 3b0af4d..9f90d86 100644 --- a/cmd/mtredisalize/changetracker.go +++ b/cmd/mtredisalize/changetracker.go @@ -31,7 +31,6 @@ func (ct *ChangeTracker) BlockChanged(key []byte) { log.Printf("decoding key failed: %s", err) return } - log.Printf("changed block: %v", coord) ct.mutex.Lock() ct.changes[quantizedXZ{X: coord.X / 16, Z: coord.Z / 16}] = true ct.mutex.Unlock() @@ -40,10 +39,17 @@ func (ct *ChangeTracker) BlockChanged(key []byte) { func (ct *ChangeTracker) FlushChanges(url string) (err error) { log.Println("change flush triggered") var oldChanges map[quantizedXZ]bool + var sendNotification bool ct.mutex.Lock() oldChanges = ct.changes - ct.changes = make(map[quantizedXZ]bool) + if len(oldChanges) > 0 { + sendNotification = true + ct.changes = make(map[quantizedXZ]bool) + } ct.mutex.Unlock() + if !sendNotification { + return + } go func() { changes := make([]quantizedXZ, len(oldChanges)) i := 0