From 042361bc0cf7c0c4a0c14ee554e0e32c6088dee8 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Fri, 1 May 2020 15:58:20 +0200 Subject: Fix template error when byteCount called with empty string --- internal/feed/template/template.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'internal') diff --git a/internal/feed/template/template.go b/internal/feed/template/template.go index 4c7b636..5a30c56 100644 --- a/internal/feed/template/template.go +++ b/internal/feed/template/template.go @@ -33,9 +33,12 @@ func lastUrlPart(url string) string { } func byteCount(str string) string { - b, err := strconv.ParseUint(str, 10, 64) - if err != nil { - log.Printf("Cannot convert '%s' to byte count: %s", str, err) + var b uint64 + if str != "" { + var err error + if b, err = strconv.ParseUint(str, 10, 64); err != nil { + log.Printf("Cannot convert '%s' to byte count: %s", str, err) + } } const unit = 1024 -- cgit v1.2.3-54-g00ecf