diff --git a/lib/blocs/upload/limits.dart b/lib/blocs/upload/limits.dart index 571e37bc4b..6dfb503c8b 100644 --- a/lib/blocs/upload/limits.dart +++ b/lib/blocs/upload/limits.dart @@ -6,7 +6,7 @@ final mobilePrivateFileSizeLimit = const GiB(10).size; final publicFileSafeSizeLimit = const GiB(5).size; -int bundleSizeLimit(bool isTurbo) => +int getBundleSizeLimit(bool isTurbo) => isTurbo ? turboBundleSizeLimit : d2nBundleSizeLimit; final d2nBundleSizeLimit = const GiB(65).size; diff --git a/lib/blocs/upload/models/upload_plan.dart b/lib/blocs/upload/models/upload_plan.dart index 0d164d3257..41a6c889cf 100644 --- a/lib/blocs/upload/models/upload_plan.dart +++ b/lib/blocs/upload/models/upload_plan.dart @@ -22,14 +22,15 @@ class UploadPlan { required this.maxDataItemCount, }); - static Future create( - {required Map fileV2UploadHandles, - required Map fileDataItemUploadHandles, - required Map - folderDataItemUploadHandles, - required TurboUploadService turboUploadService, - required int maxDataItemCount, - required bool useTurbo}) async { + static Future create({ + required Map fileV2UploadHandles, + required Map fileDataItemUploadHandles, + required Map + folderDataItemUploadHandles, + required TurboUploadService turboUploadService, + required int maxDataItemCount, + required bool useTurbo, + }) async { final uploadPlan = UploadPlan._create( fileV2UploadHandles: fileV2UploadHandles, maxDataItemCount: maxDataItemCount, @@ -59,7 +60,7 @@ class UploadPlan { }) async { logger.i( 'Creating bundle handles from data item handles with a max number of files of $maxDataItemCount'); - final int maxBundleSize = bundleSizeLimit(useTurbo); + final int maxBundleSize = getBundleSizeLimit(useTurbo); final folderItems = await NextFitBundlePacker( maxBundleSize: maxBundleSize, diff --git a/lib/blocs/upload/upload_cubit.dart b/lib/blocs/upload/upload_cubit.dart index 789ebc0eeb..c81c29b105 100644 --- a/lib/blocs/upload/upload_cubit.dart +++ b/lib/blocs/upload/upload_cubit.dart @@ -335,13 +335,12 @@ class UploadCubit extends Cubit { ), ); - _uploadMethod = uploadPreparation.uploadPaymentInfo.defaultPaymentMethod; - - logger.d('Upload method: $_uploadMethod'); - final paymentInfo = uploadPreparation.uploadPaymentInfo; final uploadPlansPreparation = uploadPreparation.uploadPlansPreparation; + _uploadMethod = paymentInfo.defaultPaymentMethod; + logger.d('Upload method: $_uploadMethod'); + if (await _profileCubit.checkIfWalletMismatch()) { emit(UploadWalletMismatch()); return; diff --git a/lib/core/upload/uploader.dart b/lib/core/upload/uploader.dart index b1c35de288..e72fa9af98 100644 --- a/lib/core/upload/uploader.dart +++ b/lib/core/upload/uploader.dart @@ -379,7 +379,7 @@ class UploadPaymentEvaluator { .getSizeOfAllV2Files(uploadPlanForAR.fileV2UploadHandles); bool isUploadEligibleToTurbo = - uploadPlanForAR.fileV2UploadHandles.isEmpty && + uploadPlanForTurbo.fileV2UploadHandles.isEmpty && uploadPlanForTurbo.bundleUploadHandles.isNotEmpty; UploadCostEstimate turboCostEstimate = UploadCostEstimate.zero(); diff --git a/lib/utils/upload_plan_utils.dart b/lib/utils/upload_plan_utils.dart index 34d5b76bba..457aab1e44 100644 --- a/lib/utils/upload_plan_utils.dart +++ b/lib/utils/upload_plan_utils.dart @@ -85,7 +85,9 @@ class UploadPlanUtils { ? RevisionAction.uploadNewVersion : RevisionAction.create; - if (fileSize < bundleSizeLimit(useTurbo)) { + final bundleSizeLimit = getBundleSizeLimit(useTurbo); + + if (fileSize < bundleSizeLimit) { fileDataItemUploadHandles[fileEntity.id!] = FileDataItemUploadHandle( entity: fileEntity, path: filePath,