From fc78d036c4027af634c996811219614ed63df615 Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Wed, 23 Apr 2025 12:07:33 +0200 Subject: [PATCH] do not set Percent if page count is zero --- pkg/pcstatus.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/pcstatus.go b/pkg/pcstatus.go index 2fb0a8a..c74cd42 100644 --- a/pkg/pcstatus.go +++ b/pkg/pcstatus.go @@ -82,7 +82,9 @@ func GetPcStatus(fname string) (PcStatus, error) { // convert to float for the occasional sparsely-cached file // see the README.md for how to produce one - pcs.Percent = (float64(pcs.Cached) / float64(pcs.Pages)) * 100.00 + if pcs.Pages != 0 { + pcs.Percent = (float64(pcs.Cached) / float64(pcs.Pages)) * 100.00 + } return pcs, nil }