Skip to content

Commit 6bcc6ef

Browse files
authored
fix: apply tasks progress instead of computed progress on pause (#818)
1 parent 0c5bafd commit 6bcc6ef

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

ios/Classes/FlutterDownloaderPlugin.m

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,9 @@ - (void)pauseTaskWithId: (NSString*)taskId
216216
NSString *taskIdValue = [weakSelf identifierForTask:download];
217217
if ([taskId isEqualToString:taskIdValue] && (state == NSURLSessionTaskStateRunning)) {
218218
NSDictionary *task = [weakSelf loadTaskWithId:taskIdValue];
219-
220-
int progress = 0;
221-
if (download.countOfBytesExpectedToReceive > 0) {
222-
int64_t bytesReceived = download.countOfBytesReceived;
223-
int64_t bytesExpectedToReceive = download.countOfBytesExpectedToReceive;
224-
progress = round(bytesReceived * 100 / (double)bytesExpectedToReceive);
225-
} else {
226-
NSNumber *progressNumOfTask = task[@"progress"];
227-
progress = progressNumOfTask.intValue;
228-
}
219+
220+
NSNumber *progressNumOfTask = task[@"progress"];
221+
int progress = progressNumOfTask.intValue;
229222

230223
[download cancelByProducingResumeData:^(NSData * _Nullable resumeData) {
231224
// Save partial downloaded data to a file

0 commit comments

Comments
 (0)