Simplify handling of intentional download failures
This commit is contained in:
@@ -178,8 +178,6 @@ public class UpdaterController implements UpdaterControllerInt {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(boolean cancelled) {
|
public void onFailure(boolean cancelled) {
|
||||||
// The client is null if we intentionally stopped the download
|
|
||||||
cancelled = mDownloads.get(downloadId).mDownloadClient == null;
|
|
||||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
Log.d(TAG, "Download cancelled");
|
Log.d(TAG, "Download cancelled");
|
||||||
@@ -366,13 +364,10 @@ public class UpdaterController implements UpdaterControllerInt {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First remove the client and then cancel the download so that when the download
|
DownloadEntry entry = mDownloads.get(downloadId);
|
||||||
// fails, we know it was intentional
|
entry.mDownloadClient.cancel();
|
||||||
DownloadClient downloadClient = mDownloads.get(downloadId).mDownloadClient;
|
removeDownloadClient(entry);
|
||||||
removeDownloadClient(mDownloads.get(downloadId));
|
entry.mUpdate.setStatus(UpdateStatus.PAUSED);
|
||||||
downloadClient.cancel();
|
|
||||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
|
||||||
update.setStatus(UpdateStatus.PAUSED);
|
|
||||||
notifyUpdateChange(downloadId);
|
notifyUpdateChange(downloadId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user