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-4808: makes turbo uploads be marked as not possible when size is below the limit #1422

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/blocs/upload/limits.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 10 additions & 9 deletions lib/blocs/upload/models/upload_plan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class UploadPlan {
required this.maxDataItemCount,
});

static Future<UploadPlan> create(
{required Map<String, FileV2UploadHandle> fileV2UploadHandles,
required Map<String, FileDataItemUploadHandle> fileDataItemUploadHandles,
required Map<String, FolderDataItemUploadHandle>
folderDataItemUploadHandles,
required TurboUploadService turboUploadService,
required int maxDataItemCount,
required bool useTurbo}) async {
static Future<UploadPlan> create({
required Map<String, FileV2UploadHandle> fileV2UploadHandles,
required Map<String, FileDataItemUploadHandle> fileDataItemUploadHandles,
required Map<String, FolderDataItemUploadHandle>
folderDataItemUploadHandles,
required TurboUploadService turboUploadService,
required int maxDataItemCount,
required bool useTurbo,
}) async {
final uploadPlan = UploadPlan._create(
fileV2UploadHandles: fileV2UploadHandles,
maxDataItemCount: maxDataItemCount,
Expand Down Expand Up @@ -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<UploadHandle>(
maxBundleSize: maxBundleSize,
Expand Down
7 changes: 3 additions & 4 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,12 @@ class UploadCubit extends Cubit<UploadState> {
),
);

_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;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/upload/uploader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class UploadPaymentEvaluator {
.getSizeOfAllV2Files(uploadPlanForAR.fileV2UploadHandles);

bool isUploadEligibleToTurbo =
uploadPlanForAR.fileV2UploadHandles.isEmpty &&
uploadPlanForTurbo.fileV2UploadHandles.isEmpty &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the reviewer - This is the relevant change.

uploadPlanForTurbo.bundleUploadHandles.isNotEmpty;

UploadCostEstimate turboCostEstimate = UploadCostEstimate.zero();
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/upload_plan_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down