Skip to content

Commit

Permalink
V8.4.3 fixes #285
Browse files Browse the repository at this point in the history
  • Loading branch information
781flyingdutchman committed Apr 12, 2024
1 parent d6dd545 commit ec82234
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions example/integration_test/downloader_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,7 @@ void main() {
lastProgress = -1; // must change to a real value
await downloader
.retrieveLocallyStoredData(); // triggers status & prog update
downloader.retrievedLocallyStoredData = false; // reset for testing
await Future.delayed(const Duration(milliseconds: 500));
expect(lastStatus, equals(TaskStatus.paused));
expect(lastProgress, equals(oldLastProgress));
Expand Down Expand Up @@ -2445,6 +2446,7 @@ void main() {
taskStatusCallback: (update) => taskStatusUpdate = update);
await Future.delayed(const Duration(milliseconds: 500));
await downloader.retrieveLocallyStoredData(); // triggers status update
downloader.retrievedLocallyStoredData = false; // reset for testing
await Future.delayed(const Duration(milliseconds: 500));
expect(taskStatusUpdate.status, equals(TaskStatus.complete));
expect(taskStatusUpdate.exception, isNull);
Expand Down Expand Up @@ -2481,6 +2483,7 @@ void main() {
taskStatusCallback: (update) => taskStatusUpdate = update);
await Future.delayed(const Duration(milliseconds: 500));
await downloader.retrieveLocallyStoredData(); // triggers status update
downloader.retrievedLocallyStoredData = false; // reset for testing
await Future.delayed(const Duration(milliseconds: 500));
expect(taskStatusUpdate.status, equals(TaskStatus.failed));
exception = taskStatusUpdate.exception as TaskHttpException;
Expand Down
7 changes: 4 additions & 3 deletions lib/src/base_downloader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ abstract base class BaseDownloader {
final canResumeTask = <Task, Completer<bool>>{};

/// Flag indicating we have retrieved missed data
var _retrievedLocallyStoredData = false;
@visibleForTesting
var retrievedLocallyStoredData = false;

/// Connected TaskQueues that will receive a signal upon task completion
final taskQueues = <TaskQueue>[];
Expand Down Expand Up @@ -180,7 +181,7 @@ abstract base class BaseDownloader {
/// Retrieve data that was stored locally because it could not be
/// delivered to the downloader
Future<void> retrieveLocallyStoredData() async {
if (!_retrievedLocallyStoredData) {
if (!retrievedLocallyStoredData) {
final resumeDataMap = await popUndeliveredData(Undelivered.resumeData);
for (var jsonString in resumeDataMap.values) {
final resumeData = ResumeData.fromJsonString(jsonString);
Expand All @@ -197,7 +198,7 @@ abstract base class BaseDownloader {
for (var jsonString in progressUpdateMap.values) {
processProgressUpdate(TaskProgressUpdate.fromJsonString(jsonString));
}
_retrievedLocallyStoredData = true;
retrievedLocallyStoredData = true;
}
}

Expand Down

0 comments on commit ec82234

Please sign in to comment.