From 217f84b57ece0222ec1671a66abeb6e67f573c3a Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Wed, 5 Jul 2017 23:35:14 +0200 Subject: [PATCH] Simplify handling of intentional download failures --- .../updater/controller/UpdaterController.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/org/lineageos/updater/controller/UpdaterController.java b/src/org/lineageos/updater/controller/UpdaterController.java index 0ad4e8a..6e32bd8 100644 --- a/src/org/lineageos/updater/controller/UpdaterController.java +++ b/src/org/lineageos/updater/controller/UpdaterController.java @@ -178,8 +178,6 @@ public class UpdaterController implements UpdaterControllerInt { @Override 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; if (cancelled) { Log.d(TAG, "Download cancelled"); @@ -366,13 +364,10 @@ public class UpdaterController implements UpdaterControllerInt { return false; } - // First remove the client and then cancel the download so that when the download - // fails, we know it was intentional - DownloadClient downloadClient = mDownloads.get(downloadId).mDownloadClient; - removeDownloadClient(mDownloads.get(downloadId)); - downloadClient.cancel(); - UpdateDownload update = mDownloads.get(downloadId).mUpdate; - update.setStatus(UpdateStatus.PAUSED); + DownloadEntry entry = mDownloads.get(downloadId); + entry.mDownloadClient.cancel(); + removeDownloadClient(entry); + entry.mUpdate.setStatus(UpdateStatus.PAUSED); notifyUpdateChange(downloadId); return true; }