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