Skip to content

Commit

Permalink
Merge pull request #1450 from ardriveapp/PE-4864-unable-to-download-f…
Browse files Browse the repository at this point in the history
…iles-in-safari

PE-4864: fix upload warning
  • Loading branch information
thiagocarvalhodev authored Oct 26, 2023
2 parents e422f69 + 48cbafb commit 9e2d47a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
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;

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"

0 comments on commit 9e2d47a

Please sign in to comment.