~xenrox/syncthing-status

5a7a2e560bd1ec99cc196688a5ec8f13ef918eed — Thorben Günther 6 months ago d601fc1
Remove division by zero

If there are no remote devices, the completion is assumed to be 100.
1 files changed, 6 insertions(+), 1 deletions(-)

M status.go
M status.go => status.go +6 -1
@@ 70,7 70,12 @@ func (client *Client) remoteStatus() *RemoteStatus {
		sum += status.Completion
	}

	totalStatus.Completion = sum / float64(len(connectedDevices))
	// Don't divide by zero
	if len(connectedDevices) == 0 {
		totalStatus.Completion = 100
	} else {
		totalStatus.Completion = sum / float64(len(connectedDevices))
	}

	return &totalStatus
}