From fb8227a1f31a86b30cb54ce4b599e8a4c37391ae Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 6 Jun 2019 07:09:05 +0100 Subject: [PATCH] prevent division by zero --- .../groovy/com/muwire/core/download/DownloadSession.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy index ec6bb3f6..0697548d 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy @@ -195,7 +195,8 @@ class DownloadSession { return reads[idx] long interval = timestamps.last - timestamps[idx] - + if (interval == 0) + interval = 0.001 for (int i = idx; i < SAMPLES; i++) totalRead += reads[idx] (int)(totalRead * 1000.0 / interval)