From ed3d467329c06f3525c3029f93f96d26b1c3ec04 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Tue, 24 Mar 2015 10:27:11 +0100 Subject: [PATCH] DownloadableContributionsDownloader: fixed wrong math when downloading partially downloaded files --- .../packages/DownloadableContributionsDownloader.java | 4 ++-- arduino-core/src/cc/arduino/utils/network/FileDownloader.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java b/arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java index 6e034a823..908df52a2 100644 --- a/arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java +++ b/arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java @@ -85,8 +85,8 @@ public class DownloadableContributionsDownloader { FileDownloader me = (FileDownloader) o; String msg = ""; if (me.getDownloadSize() != null) { - long downloaded = me.getInitialSize() + me.getDownloaded() / 1000; - long total = me.getInitialSize() + me.getDownloadSize() / 1000; + long downloaded = (me.getInitialSize() + me.getDownloaded()) / 1000; + long total = (me.getInitialSize() + me.getDownloadSize()) / 1000; msg = format(_("Downloaded {0}kb of {1}kb."), downloaded, total); } progress.setStatus(statusText + " " + msg); diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java index a3e66c8a5..f686ab2e7 100644 --- a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java +++ b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java @@ -181,8 +181,9 @@ public class FileDownloader extends Observable { // Check for valid content length. long len = connection.getContentLength(); - if (len >= 0) + if (len >= 0) { setDownloadSize(len); + } setStatus(Status.DOWNLOADING); synchronized (this) {