Update download size only if it was unknown

The returned content-length depends on the requested range, therefore
when resuming download the reported size is smaller than the actual
file size and we should not update it.
This commit is contained in:
Gabriele M
2017-07-15 02:09:13 +02:00
parent 66ca7a79df
commit d30ba00a7b

View File

@@ -152,6 +152,7 @@ public class UpdaterController implements UpdaterControllerInt {
@Override
public void onResponse(int statusCode, String url, DownloadClient.Headers headers) {
final UpdateDownload update = mDownloads.get(downloadId).mUpdate;
if (update.getFileSize() <= 0) {
String contentLenght = headers.get("Content-Length");
if (contentLenght != null) {
try {
@@ -163,6 +164,7 @@ public class UpdaterController implements UpdaterControllerInt {
Log.e(TAG, "Could not get content-length");
}
}
}
update.setStatus(UpdateStatus.DOWNLOADING);
update.setPersistentStatus(UpdateStatus.Persistent.INCOMPLETE);
new Thread(new Runnable() {