Verify package when resuming a completed download
It's possible to resume already completed downloads. When this happens, starts verifying the package. Otherwise we won't be able to resume the download since the server will likely reply with 416.
This commit is contained in:
@@ -295,6 +295,13 @@ public class UpdaterController implements UpdaterControllerInt {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||||
|
File file = update.getFile();
|
||||||
|
if (file.exists() && file.length() == update.getFileSize()) {
|
||||||
|
Log.d(TAG, "File already downloaded, starting verification");
|
||||||
|
update.setStatus(UpdateStatus.VERIFYING);
|
||||||
|
verifyUpdateAsync(downloadId);
|
||||||
|
notifyUpdateChange(downloadId);
|
||||||
|
} else {
|
||||||
mDownloads.get(downloadId).mDownloadClient =
|
mDownloads.get(downloadId).mDownloadClient =
|
||||||
DownloadClient.downloadFileResume(update.getDownloadUrl(),
|
DownloadClient.downloadFileResume(update.getDownloadUrl(),
|
||||||
update.getFile(),
|
update.getFile(),
|
||||||
@@ -303,6 +310,7 @@ public class UpdaterController implements UpdaterControllerInt {
|
|||||||
update.setStatus(UpdateStatus.STARTING);
|
update.setStatus(UpdateStatus.STARTING);
|
||||||
notifyUpdateChange(downloadId);
|
notifyUpdateChange(downloadId);
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user