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-4864: fix upload warning #1450

Merged
merged 2 commits into from
Oct 26, 2023
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
5 changes: 4 additions & 1 deletion lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ class UploadCubit extends Cubit<UploadState> {
if (configService.config.useNewUploader) {
if (_uploadMethod == UploadMethod.turbo) {
await _verifyIfUploadContainsLargeFilesUsingTurbo();
if (!hasEmittedWarning && kIsWeb && !await AppPlatform.isChrome()) {
if ((_containsLargeTurboUpload ?? false) &&
!hasEmittedWarning &&
kIsWeb &&
!await AppPlatform.isChrome()) {
emit(
UploadShowingWarning(
reason: UploadWarningReason.fileTooLargeOnNonChromeBrowser,
Expand Down
20 changes: 18 additions & 2 deletions packages/ardrive_uploader/lib/src/data_bundler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ class DataTransactionBundler implements DataBundler<TransactionResult> {
Function? onStartBundleCreation,
Function? onFinishBundleCreation,
}) async {
SecretKey? key;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a better name is fileKey


if (driveKey != null) {
key = await deriveFileKey(
driveKey,
metadata.id,
keyByteLength,
);
onStartEncryption?.call();
} else {
onStartBundling?.call();
Expand All @@ -103,7 +110,7 @@ class DataTransactionBundler implements DataBundler<TransactionResult> {
fileLength: await file.length,
metadata: metadata,
wallet: wallet,
encryptionKey: driveKey,
encryptionKey: key,
);

onStartMetadataCreation?.call();
Expand Down Expand Up @@ -360,14 +367,23 @@ class BDIDataBundler implements DataBundler<DataItemResult> {
print('Creating bundle for file: ${file.path}');
onStartMetadataCreation?.call();
print('Creating metadata data item');
SecretKeyData? key;

if (driveKey != null) {
key = await deriveFileKey(
driveKey,
metadata.id,
keyByteLength,
);
}

// returns the encrypted or not file read stream and the cipherIv if it was encrypted
final dataGenerator = await _dataGenerator(
dataStream: file.openReadStream,
fileLength: await file.length,
metadata: metadata,
wallet: wallet,
encryptionKey: driveKey,
encryptionKey: key,
);

final metadataDataItem = await _generateMetadataDataItemForFile(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2306,5 +2306,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.1.0 <4.0.0"
dart: ">=3.1.3 <4.0.0"
flutter: ">=3.13.6"
Loading