From ba676f281070d2c82ce333ddd8bf529957fcd13e Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 27 Aug 2015 21:41:39 +0200 Subject: [PATCH] Dividing by zero is frowned upon --- cmd/syncthing/verbose.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/syncthing/verbose.go b/cmd/syncthing/verbose.go index 125ef1cd..9e9f90a0 100644 --- a/cmd/syncthing/verbose.go +++ b/cmd/syncthing/verbose.go @@ -125,7 +125,11 @@ func (s *verboseSvc) formatEvent(ev events.Event) string { folder := data["folder"].(string) current := data["current"].(int64) total := data["total"].(int64) - return fmt.Sprintf("Scanning folder %q, %d%% done", folder, 100*current/total) + var pct int64 + if total > 0 { + pct = 100 * current / total + } + return fmt.Sprintf("Scanning folder %q, %d%% done", folder, pct) case events.DevicePaused: data := ev.Data.(map[string]string)