From 27f7bdb39070e6741958b6584b8d54fbe25f7093 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Fri, 25 Aug 2006 18:36:46 +0000 Subject: [PATCH] Report 0% done if the _totalSize is 0, because it's better than reporting 2147483647% done. The real problem here is that the TorrentDownloader never sets _totalSize. --- src/java/com/threerings/getdown/launcher/Downloader.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/getdown/launcher/Downloader.java b/src/java/com/threerings/getdown/launcher/Downloader.java index 401eec7..6487b14 100644 --- a/src/java/com/threerings/getdown/launcher/Downloader.java +++ b/src/java/com/threerings/getdown/launcher/Downloader.java @@ -182,11 +182,11 @@ public abstract class Downloader extends Thread long bps = (secs == 0) ? 0 : (_currentSize / secs); // compute our percentage completion - int pctdone = (int)( - (_currentSize / (float)_totalSize) * 100f); + int pctdone = (_totalSize == 0) ? 0 : + (int)((_currentSize * 100f) / _totalSize); // estimate our time remaining - long remaining = (bps <= 0) ? -1 : + long remaining = (bps <= 0 || _totalSize == 0) ? -1 : (_totalSize - _currentSize) / bps; // make sure we only report 100% exactly once