mirror of
				https://bitbucket.org/s_l_teichmann/mtsatellite
				synced 2025-11-04 01:55:25 +01:00 
			
		
		
		
	Do nort send notifications if nothing changed.
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user