diff --git a/CHANGELOG.md b/CHANGELOG.md index 09081a1..4bba3d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 8.4.3 + +* Fixes iOS/Android issue where `retrieveLocallyStoredData` retrieves only a basic `TaskStatusUpdate`, without responseCode, responseBody etc + ## 8.4.2 * Fixes iOS/Android bug with ParallelDownloadTask hanging when number of chunks exceeds ~10 diff --git a/android/src/main/kotlin/com/bbflight/background_downloader/TaskWorker.kt b/android/src/main/kotlin/com/bbflight/background_downloader/TaskWorker.kt index 4f5653a..dd0944f 100644 --- a/android/src/main/kotlin/com/bbflight/background_downloader/TaskWorker.kt +++ b/android/src/main/kotlin/com/bbflight/background_downloader/TaskWorker.kt @@ -160,38 +160,30 @@ open class TaskWorker( // Post update if task expects one, or if failed and retry is needed if (canSendStatusUpdate && (task.providesStatusUpdates() || retryNeeded)) { - val finalTaskException = taskException ?: TaskException(ExceptionType.general) - val taskStatusUpdate = if (status == TaskStatus.failed) TaskStatusUpdate( - task = task, - taskStatus = status, - exception = finalTaskException, - responseBody = responseBody, - responseStatusCode = null, - responseHeaders = responseHeaders?.filterNotNull()?.mapKeys { it.key.lowercase() }, - mimeType = mimeType, - charSet = charSet - ) else if (status.isFinalState()) { // last update gets all data except exception - TaskStatusUpdate( + val taskStatusUpdate = + if (status.isFinalState()) { // last update gets all data + TaskStatusUpdate( + task = task, + taskStatus = status, + exception = if (status == TaskStatus.failed) taskException + ?: TaskException(ExceptionType.general) else null, + responseBody = responseBody, + responseStatusCode = if (status == TaskStatus.complete || status == TaskStatus.notFound) responseStatusCode else null, + responseHeaders = responseHeaders?.filterNotNull() + ?.mapKeys { it.key.lowercase() }, + mimeType = mimeType, + charSet = charSet + ) + } else TaskStatusUpdate( // interim updates are limited task = task, taskStatus = status, exception = null, - responseBody = responseBody, - responseStatusCode = if (status == TaskStatus.complete || status == TaskStatus.notFound) responseStatusCode else null, - responseHeaders = responseHeaders?.filterNotNull() - ?.mapKeys { it.key.lowercase() }, - mimeType = mimeType, - charSet = charSet + responseBody = null, + responseStatusCode = null, + responseHeaders = null, + mimeType = null, + charSet = null ) - } else TaskStatusUpdate( // interim updates are limited - task = task, - taskStatus = status, - exception = null, - responseBody = null, - responseStatusCode = null, - responseHeaders = null, - mimeType = null, - charSet = null - ) val arg = taskStatusUpdate.argList postOnBackgroundChannel("statusUpdate", task, arg, onFail = { // unsuccessful post, so store in local prefs diff --git a/pubspec.yaml b/pubspec.yaml index 0ab3443..73cec90 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: background_downloader description: A multi-platform background file downloader and uploader. Define the task, enqueue and monitor progress -version: 8.4.2 +version: 8.4.3 repository: https://github.com/781flyingdutchman/background_downloader environment: