Skip to content

Commit

Permalink
V8.4.3RC fixes #285
Browse files Browse the repository at this point in the history
  • Loading branch information
781flyingdutchman committed Apr 12, 2024
1 parent 3ee3e39 commit d6dd545
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit d6dd545

Please sign in to comment.