1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

DownloadableContributionsDownloader: fixed wrong math when downloading partially downloaded files

This commit is contained in:
Federico Fissore
2015-03-24 10:27:11 +01:00
parent e646ca2525
commit ed3d467329
2 changed files with 4 additions and 3 deletions

View File

@ -85,8 +85,8 @@ public class DownloadableContributionsDownloader {
FileDownloader me = (FileDownloader) o; FileDownloader me = (FileDownloader) o;
String msg = ""; String msg = "";
if (me.getDownloadSize() != null) { if (me.getDownloadSize() != null) {
long downloaded = me.getInitialSize() + me.getDownloaded() / 1000; long downloaded = (me.getInitialSize() + me.getDownloaded()) / 1000;
long total = me.getInitialSize() + me.getDownloadSize() / 1000; long total = (me.getInitialSize() + me.getDownloadSize()) / 1000;
msg = format(_("Downloaded {0}kb of {1}kb."), downloaded, total); msg = format(_("Downloaded {0}kb of {1}kb."), downloaded, total);
} }
progress.setStatus(statusText + " " + msg); progress.setStatus(statusText + " " + msg);

View File

@ -181,8 +181,9 @@ public class FileDownloader extends Observable {
// Check for valid content length. // Check for valid content length.
long len = connection.getContentLength(); long len = connection.getContentLength();
if (len >= 0) if (len >= 0) {
setDownloadSize(len); setDownloadSize(len);
}
setStatus(Status.DOWNLOADING); setStatus(Status.DOWNLOADING);
synchronized (this) { synchronized (this) {