Skip to content

Commit

Permalink
Merge branch 'dev' into PE-6222-add-health-check-option-on-dev-tools-…
Browse files Browse the repository at this point in the history
…panel
  • Loading branch information
thiagocarvalhodev committed Jun 24, 2024
2 parents 4128738 + db6bcaa commit cfda4f0
Show file tree
Hide file tree
Showing 37 changed files with 2,207 additions and 942 deletions.
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-US/changelogs/129.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Enhanced upload logging for better error insights and improved retry mechanism
2 changes: 2 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/130.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improves handling of a few common errors
- Enhances empty drive and folder view
4 changes: 4 additions & 0 deletions lib/blocs/drives/drives_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class DrivesCubit extends Cubit<DrivesState> {
drivesWithAlerts: const [],
canCreateNewDrive: false);

if (isClosed) {
return;
}

emit(state);
}

Expand Down
21 changes: 14 additions & 7 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,18 @@ class UploadCubit extends Cubit<UploadState> {
);

uploadController.onError((tasks) {
logger.e('Error uploading folders. Number of tasks: ${tasks.length}');
addError(Exception('Error uploading'));
logger.i('Error uploading folders. Number of tasks: ${tasks.length}');
emit(UploadFailure(
error: UploadErrors.unknown,
failedTasks: tasks,
controller: uploadController));
hasEmittedError = true;
});

uploadController.onFailedTask((task) {
logger.e('UploadTask failed. Task: ${task.errorInfo()}', task.error);
});

uploadController.onProgressChange(
(progress) {
emit(
Expand Down Expand Up @@ -651,8 +658,6 @@ class UploadCubit extends Cubit<UploadState> {

void retryUploads() {
if (state is UploadFailure) {
logger.i('Retrying uploads');

final controller = (state as UploadFailure).controller!;

controller.retryFailedTasks(_auth.currentUser.wallet);
Expand Down Expand Up @@ -722,7 +727,7 @@ class UploadCubit extends Cubit<UploadState> {
);

uploadController.onError((tasks) {
logger.e('Error uploading files. Number of tasks: ${tasks.length}');
logger.i('Error uploading files. Number of tasks: ${tasks.length}');
hasEmittedError = true;
emit(
UploadFailure(
Expand All @@ -733,10 +738,13 @@ class UploadCubit extends Cubit<UploadState> {
);
});

uploadController.onFailedTask((task) {
logger.e('UploadTask failed. Task: ${task.errorInfo()}', task.error);
});

uploadController.onProgressChange(
(progress) async {
// TODO: Save as the file is finished the upload

emit(
UploadInProgressUsingNewUploader(
progress: progress,
Expand Down Expand Up @@ -961,7 +969,6 @@ class UploadCubit extends Cubit<UploadState> {
}

emit(UploadFailure(error: UploadErrors.unknown));
logger.e('Failed to upload file', error, stackTrace);
super.onError(error, stackTrace);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/components/folder_create_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class _FolderCreateFormState extends State<FolderCreateForm> {
showProgressDialog(
context,
title: appLocalizationsOf(context).creatingFolderEmphasized,
useNewArDriveUI: true,
);
} else if (state is FolderCreateSuccess) {
Navigator.pop(context);
Expand All @@ -91,14 +92,15 @@ class _FolderCreateFormState extends State<FolderCreateForm> {
description: appLocalizationsOf(context).entityAlreadyExists(
state.folderName,
),
useNewArDriveUI: true,
);
}
},
builder: (context, state) => ArDriveStandardModal(
builder: (context, state) => ArDriveStandardModalNew(
title: appLocalizationsOf(context).createFolderEmphasized,
content: SizedBox(
width: kMediumDialogWidth,
child: ArDriveTextField(
child: ArDriveTextFieldNew(
controller: _folderNameController,
autofocus: true,
onFieldSubmitted: (value) {
Expand Down
25 changes: 9 additions & 16 deletions lib/components/pin_file_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ class PinFileDialog extends StatelessWidget {
final idValidationError = _getIdValidationError(context, state);
final nameValidationError = _getNameValidationError(context, state);

return ArDriveStandardModal(
return ArDriveStandardModalNew(
title: appLocalizationsOf(context).newFilePin,
content: SizedBox(
width: kMediumDialogWidth,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ArDriveTextField(
ArDriveTextFieldNew(
isEnabled: state is! PinFileNetworkCheckRunning,
label: appLocalizationsOf(context).enterTxIdOrFileId,
isFieldRequired: true,
Expand All @@ -119,7 +119,7 @@ class PinFileDialog extends StatelessWidget {
);
},
),
ArDriveTextField(
ArDriveTextFieldNew(
isEnabled: true,
label: appLocalizationsOf(context).enterFileName,
isFieldRequired: true,
Expand Down Expand Up @@ -154,10 +154,6 @@ class PinFileDialog extends StatelessWidget {
}

String? _getIdValidationError(BuildContext context, PinFileState state) {
// if (state is PinFileInitial) {
// return null;
// }

if (state.idValidation == IdValidationResult.invalid) {
return appLocalizationsOf(context).theIdProvidedIsNotValid;
} else if (state.idValidation == IdValidationResult.required) {
Expand All @@ -183,10 +179,6 @@ class PinFileDialog extends StatelessWidget {
}

String? _getNameValidationError(BuildContext context, PinFileState state) {
// if (state is PinFileInitial) {
// return null;
// }

if (state.nameValidation == NameValidationResult.invalid) {
return appLocalizationsOf(context).validationInvalid;
} else if (state.nameValidation == NameValidationResult.required) {
Expand All @@ -197,21 +189,22 @@ class PinFileDialog extends StatelessWidget {
return null;
}

ArDriveStandardModal _errorDialog(
ArDriveStandardModalNew _errorDialog(
BuildContext context, {
required String errorText,
bool doublePop = false,
}) =>
ArDriveStandardModal(
ArDriveStandardModalNew(
width: kMediumDialogWidth,
title: appLocalizationsOf(context).failedToCreatePin,
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 16),
Text(errorText),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(errorText),
),
],
),
actions: [
Expand Down
2 changes: 2 additions & 0 deletions lib/components/progress_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ Future<void> showProgressDialog(
BuildContext context, {
required String title,
List<ModalAction>? actions,
bool useNewArDriveUI = false,
}) =>
showArDriveDialog(
context,
barrierDismissible: false,
content: ProgressDialog(
title: title,
actions: actions ?? const [],
useNewArDriveUI: useNewArDriveUI,
),
);

Expand Down
1 change: 0 additions & 1 deletion lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ class _UploadFormState extends State<UploadForm> {
],
);
} else if (state is UploadFailure) {
logger.e('Upload failed: ${state.error}');
if (state.error == UploadErrors.turboTimeout) {
return ArDriveStandardModal(
title: appLocalizationsOf(context).uploadFailed,
Expand Down
8 changes: 7 additions & 1 deletion lib/core/crypto/crypto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ class ArDriveCrypto {
final cipherIvTag = transaction.getTag(EntityTag.cipherIv);

if (cipher == null || cipherIvTag == null) {
throw MissingCipherTagException();
throw MissingCipherTagException(
corruptedDataAppVersion: transaction.getTag(EntityTag.appVersion),
corruptedTransactionId: transaction.id,
);
}

final cipherIv = utils.decodeBase64ToBytes(cipherIvTag);
Expand Down Expand Up @@ -128,6 +131,7 @@ class ArDriveCrypto {
} else {
throw UnknownCipherException(
corruptedDataAppVersion: transaction.getTag(EntityTag.appVersion),
corruptedTransactionId: transaction.id,
);
}

Expand All @@ -143,6 +147,7 @@ class ArDriveCrypto {
/// Unknow error
throw TransactionDecryptionException(
corruptedDataAppVersion: transaction.getTag(EntityTag.appVersion),
corruptedTransactionId: transaction.id,
);
}
}
Expand All @@ -161,6 +166,7 @@ class ArDriveCrypto {
if (cipher == null || cipherIvTag == null) {
throw MissingCipherTagException(
corruptedDataAppVersion: transaction.getTag(EntityTag.appVersion),
corruptedTransactionId: transaction.id,
);
}

Expand Down
Loading

0 comments on commit cfda4f0

Please sign in to comment.