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.
This commit is contained in:
Ray Greenwell
2006-08-25 18:36:46 +00:00
parent 14d823a930
commit 27f7bdb390
@@ -182,11 +182,11 @@ public abstract class Downloader extends Thread
long bps = (secs == 0) ? 0 : (_currentSize / secs); long bps = (secs == 0) ? 0 : (_currentSize / secs);
// compute our percentage completion // compute our percentage completion
int pctdone = (int)( int pctdone = (_totalSize == 0) ? 0 :
(_currentSize / (float)_totalSize) * 100f); (int)((_currentSize * 100f) / _totalSize);
// estimate our time remaining // estimate our time remaining
long remaining = (bps <= 0) ? -1 : long remaining = (bps <= 0 || _totalSize == 0) ? -1 :
(_totalSize - _currentSize) / bps; (_totalSize - _currentSize) / bps;
// make sure we only report 100% exactly once // make sure we only report 100% exactly once