-
Notifications
You must be signed in to change notification settings - Fork 19
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
PE-4949: feat(bdi strategy upload) #1490
PE-4949: feat(bdi strategy upload) #1490
Conversation
- implements the `UploadFileStrategy` to abstract the logic for how we upload the file using a bundle or data items - implemented factories and their tests - FIX ME: I noticed a problem on updating the status of the upload
Visit the preview URL for this PR (updated for commit 99cd461): https://ardrive-web--pr1490-pe-4949-change-bdi-s-bgtf0kp4.web.app (expires Mon, 15 Jan 2024 19:26:10 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: a224ebaee2f0939e7665e7630e7d3d6cd7d0f8b0 |
remove prints
- decouples the controller from low-level classes like the streamed upload - refactors on the UploadTask APIs and on the UploadController FIX ME: there's a problem with the worker pool. Only from the second onwards are uploading. The first worker never uploads.
- fixes the worker pool not uploading the first task of each worker
remove unused elements
- implement a class to upload the folder structure as bundle
- add error handling UI
- introduces new classes for the exceptions on the uploader - improves the error handling on the TurboUploadService, UploadStrategy, StreamedUpload, and UploadDispatcher classes
- reset progress
…for-turbo-uploads-with-refactors PE-4949: (WIP): refactors and unit tests
…-ar-drive-app-v-2-27-0
- resets the total size when retrying the uploads
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.
Approved with comments.
@@ -746,14 +747,26 @@ class _UploadFormState extends State<UploadForm> { | |||
} | |||
|
|||
return ArDriveStandardModal( | |||
title: appLocalizationsOf(context).uploadFailed, | |||
width: kLargeDialogWidth, | |||
title: 'Problem with Upload', |
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.
Has to be localized.
: [ | ||
ModalAction( | ||
action: () => Navigator.of(context).pop(false), | ||
title: 'Do Not Fix', |
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.
Has to be localized.
action: () { | ||
context.read<UploadCubit>().retryUploads(); | ||
}, | ||
title: 'Re-Upload', |
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.
Has to be localized.
'${filesize(((task.uploadItem!.size) * task.progress).ceil())}/${filesize(task.uploadItem!.size)}'; | ||
if (task.uploadItem != null) { | ||
progressText = | ||
'${filesize(((task.uploadItem!.size) * task.progress).ceil())}/${filesize(task.uploadItem!.size)}'; |
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.
We could factor this out into its own testable and atomic function.
Text( | ||
'It seems there was a partial failure uploading the following file(s). The file(s) will show as failed in your drive. Please re-upload to fix.', |
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.
Has to be localized.
@@ -0,0 +1,103 @@ | |||
abstract class ArDriveUploaderExceptions { |
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.
Nit
abstract class ArDriveUploaderExceptions { | |
abstract class ArDriveUploaderException { |
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.
Also, I'd say it should extend Exception
.
default: | ||
throw Exception('Invalid upload type'); |
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.
If UploadType
is an enum with those two values then there's no default, so we shouldn't throw.
default: | ||
throw Exception('Invalid upload type'); |
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.
Same: no default needed.
if (type == UploadType.d2n) { | ||
return D2NStreamedUpload(); | ||
} else if (type == UploadType.turbo) { | ||
return TurboStreamedUpload( | ||
TurboUploadServiceImpl( | ||
turboUploadUri: turboUploadUri, | ||
), | ||
); | ||
} else { | ||
throw Exception('Invalid upload type'); | ||
} |
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.
Consider using a switch-case with no default instead.
Future<R> send( | ||
class StreamedUploadResult { | ||
final bool success; | ||
final Object? error; |
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.
Should it be something like...
final Exception? exception;
@matibat's comments will be addressed on a new task. |
UploadFileStrategy
to abstract the logic for how we upload the file using a bundle or data items--- Releases ---
Android release: https://appdistribution.firebase.google.com/testerapps/1:305132849030:android:6cf0cd5ec064fad3ffce07/releases/6ra020rgoe8ro