Skip to content
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

Merged
merged 19 commits into from
Jan 9, 2024

Conversation

thiagocarvalhodev
Copy link
Collaborator

@thiagocarvalhodev thiagocarvalhodev commented Nov 27, 2023

  • 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

--- Releases ---
Android release: https://appdistribution.firebase.google.com/testerapps/1:305132849030:android:6cf0cd5ec064fad3ffce07/releases/6ra020rgoe8ro

- 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
@thiagocarvalhodev thiagocarvalhodev self-assigned this Nov 27, 2023
Copy link

github-actions bot commented Nov 27, 2023

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

thiagocarvalhodev and others added 13 commits November 28, 2023 09:39
- 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
- Split UploadStrategy into two new classes: for file and folders.
- implement unit tests on the factories
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
@thiagocarvalhodev thiagocarvalhodev marked this pull request as ready for review December 7, 2023 14:43
karlprieb
karlprieb previously approved these changes Dec 12, 2023
- resets the total size when retrying the uploads
Copy link
Contributor

@matibat matibat left a 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',
Copy link
Contributor

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',
Copy link
Contributor

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',
Copy link
Contributor

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)}';
Copy link
Contributor

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.

Comment on lines +1177 to +1178
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.',
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
abstract class ArDriveUploaderExceptions {
abstract class ArDriveUploaderException {

Copy link
Contributor

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.

Comment on lines +37 to +38
default:
throw Exception('Invalid upload type');
Copy link
Contributor

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.

Comment on lines +91 to +92
default:
throw Exception('Invalid upload type');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: no default needed.

Comment on lines +107 to +117
if (type == UploadType.d2n) {
return D2NStreamedUpload();
} else if (type == UploadType.turbo) {
return TurboStreamedUpload(
TurboUploadServiceImpl(
turboUploadUri: turboUploadUri,
),
);
} else {
throw Exception('Invalid upload type');
}
Copy link
Contributor

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;
Copy link
Contributor

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;

@thiagocarvalhodev
Copy link
Collaborator Author

@matibat's comments will be addressed on a new task.

@thiagocarvalhodev thiagocarvalhodev merged commit 45b0c49 into dev Jan 9, 2024
6 checks passed
@thiagocarvalhodev thiagocarvalhodev deleted the PE-4949-change-bdi-strategy-for-turbo-uploads branch January 9, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants