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