-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to change [FileMode] of the download by introducing [Dio… #2281
Open
shehabmohamed0
wants to merge
15
commits into
cfug:main
Choose a base branch
from
shehabmohamed0:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fe609eb
Add ability to change [FileMode] of the download by introducing [Dio…
shehabmohamed0 3266e0f
Add append download test with the new [DioFileMode]
shehabmohamed0 53a762d
Merge branch 'main' into main
shehabmohamed0 cf5f6bf
Apply dart formatting
shehabmohamed0 87ad6d2
Merge branch 'main' into main
shehabmohamed0 66de32f
Merge branch 'main' into main
shehabmohamed0 8eee312
change dio_file_mode.dart to file_access_mode.dart
shehabmohamed0 0c4614c
Merge branch 'main' into main
shehabmohamed0 6f2d1ab
Merge branch 'main' into main
shehabmohamed0 9a9ee71
Merge branch 'main' into main
shehabmohamed0 27bb332
Apply suggestions from code review
shehabmohamed0 4276742
Moving FileAccessMode from "file_access_mode.dart" to "options.dart"
shehabmohamed0 238e185
Merge branch 'main' into main
shehabmohamed0 6c45ae5
Fix [FileAccessMode] comments in dio/lib/src/dio.dart
shehabmohamed0 c2a23e8
format dio_test/lib/src/test/download_tests.dart
shehabmohamed0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,6 +286,7 @@ abstract class DioMixin implements Dio { | |
ProgressCallback? onReceiveProgress, | ||
CancelToken? cancelToken, | ||
bool deleteOnError = true, | ||
FileAccessMode mode = FileAccessMode.write, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
String lengthHeader = Headers.contentLengthHeader, | ||
Object? data, | ||
Options? options, | ||
|
@@ -310,6 +311,7 @@ abstract class DioMixin implements Dio { | |
Map<String, dynamic>? queryParameters, | ||
CancelToken? cancelToken, | ||
bool deleteOnError = true, | ||
FileAccessMode fileAccessMode = FileAccessMode.write, | ||
String lengthHeader = Headers.contentLengthHeader, | ||
Object? data, | ||
Options? options, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -380,6 +380,55 @@ void downloadTests( | |||||
completes, | ||||||
); | ||||||
}); | ||||||
|
||||||
test('append bytes to previous download', () async { | ||||||
shehabmohamed0 marked this conversation as resolved.
Show resolved
Hide resolved
shehabmohamed0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
final cancelToken = CancelToken(); | ||||||
final path = p.join(tmp.path, 'download_3.txt'); | ||||||
final requestedBytes = 1024 * 1024 * 10; | ||||||
var recievedBytes1 = 0; | ||||||
await expectLater( | ||||||
dio.download( | ||||||
'/bytes/$requestedBytes', | ||||||
path, | ||||||
cancelToken: cancelToken, | ||||||
onReceiveProgress: (c, t) { | ||||||
if (c > 5000) { | ||||||
AlexV525 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
recievedBytes1 = c; | ||||||
cancelToken.cancel(); | ||||||
} | ||||||
}, | ||||||
deleteOnError: false, | ||||||
), | ||||||
throwsDioException( | ||||||
DioExceptionType.cancel, | ||||||
stackTraceContains: 'test/download_tests.dart', | ||||||
), | ||||||
); | ||||||
|
||||||
final cancelToken2 = CancelToken(); | ||||||
var recievedBytes2 = 0; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
expectLater( | ||||||
dio.download( | ||||||
'/bytes/$requestedBytes', | ||||||
path, | ||||||
cancelToken: cancelToken, | ||||||
onReceiveProgress: (c, t) { | ||||||
recievedBytes2 = c; | ||||||
if (c > 5000) { | ||||||
cancelToken2.cancel(); | ||||||
} | ||||||
}, | ||||||
deleteOnError: false, | ||||||
fileAccessMode: FileAccessMode.append, | ||||||
), | ||||||
throwsDioException( | ||||||
DioExceptionType.cancel, | ||||||
stackTraceContains: 'test/download_tests.dart', | ||||||
), | ||||||
); | ||||||
await Future.delayed(const Duration(milliseconds: 100), () {}); | ||||||
expect(File(path).lengthSync(), recievedBytes1 + recievedBytes2); | ||||||
}); | ||||||
}, | ||||||
testOn: 'vm', | ||||||
); | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this should be
fileAccessMode
.