diff --git a/library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java b/library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java index 63eb6197..0f179617 100644 --- a/library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java +++ b/library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java @@ -263,7 +263,10 @@ public void run() { handleFirstConnected(firstConnectionTask.getRequestHeader(), firstConnectionTask, connection); - if (paused) return; + if (paused) { + model.setStatus(FileDownloadStatus.paused); + return; + } // 2. fetch checkupBeforeFetch(); @@ -290,7 +293,11 @@ public void run() { " must be larger than 0", connection)); } - if (paused) return; + if (paused) { + model.setStatus(FileDownloadStatus.paused); + return; + } + isSingleConnection = connectionCount == 1; if (isSingleConnection) { // single connection @@ -504,8 +511,12 @@ private void fetchWithSingleConnection(final ConnectionProfile profile, FileDown model.setConnectionCount(1); database.updateConnectionCount(model.getId(), 1); singleFetchDataTask = builder.build(); - singleFetchDataTask.run(); - if (paused) singleFetchDataTask.pause(); + if (paused) { + model.setStatus(FileDownloadStatus.paused); + singleFetchDataTask.pause(); + } else { + singleFetchDataTask.run(); + } } private void fetchWithMultipleConnectionFromResume(final int connectionCount, final List connectionModelList) throws InterruptedException { @@ -623,7 +634,10 @@ private void fetchWithMultipleConnection(final List connectionM } subTasks.add(Executors.callable(runnable)); } - if (paused) return; + if (paused) { + model.setStatus(FileDownloadStatus.paused); + return; + } List> subTaskFutures = DOWNLOAD_EXECUTOR.invokeAll(subTasks); if (FileDownloadLog.NEED_LOG) {