From 5a7a2e560bd1ec99cc196688a5ec8f13ef918eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 13 Feb 2022 21:30:30 +0100 Subject: [PATCH] Remove division by zero If there are no remote devices, the completion is assumed to be 100. --- status.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/status.go b/status.go index 37c30eb..ee188e7 100644 --- a/status.go +++ b/status.go @@ -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 } -- 2.44.0