From 7c429460196a382f0c0ca38454249d23fbd269ba Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:40:44 -0300 Subject: [PATCH] Update data_bundler.dart --- .../lib/src/data_bundler.dart | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/ardrive_uploader/lib/src/data_bundler.dart b/packages/ardrive_uploader/lib/src/data_bundler.dart index 202982b00d..21db6c7750 100644 --- a/packages/ardrive_uploader/lib/src/data_bundler.dart +++ b/packages/ardrive_uploader/lib/src/data_bundler.dart @@ -64,21 +64,26 @@ class DataTransactionBundler implements DataBundler { Function? onStartBundleCreation, Function? onFinishBundleCreation, }) async { - final uploadPreparation = await prepareDataItems( - file: file, - metadata: metadata, - wallet: wallet, - driveKey: driveKey, - onStartMetadataCreation: onStartMetadataCreation, - onFinishMetadataCreation: onFinishMetadataCreation, - ); + List dataItemFilesToUse = []; + if (dataItemFiles == null) { + final uploadPreparation = await prepareDataItems( + file: file, + metadata: metadata, + wallet: wallet, + driveKey: driveKey, + onStartMetadataCreation: onStartMetadataCreation, + onFinishMetadataCreation: onFinishMetadataCreation, + ); - dataItemFiles ??= uploadPreparation.dataItemFiles; + dataItemFilesToUse = uploadPreparation.dataItemFiles; + } else { + dataItemFilesToUse = dataItemFiles; + } onStartBundleCreation?.call(); final transactionResult = await createDataBundleTransaction( - dataItemFiles: dataItemFiles, + dataItemFiles: dataItemFilesToUse, wallet: wallet, tags: getBundleTags(AppInfoServices(), customBundleTags) .map((e) => createTag(e.name, e.value)) @@ -442,6 +447,8 @@ Future _generateMetadataDataItem({ print(StackTrace.current); throw l; }, (metadataDataItem) { + logger.d( + 'Metadata tx id: on _generateMetadataDataItem ${metadataDataItem.id}'); metadata.setMetadataTxId = metadataDataItem.id; return metadataDataItem; }); @@ -520,6 +527,8 @@ Future _generateFileMetadataDataItem({ metadataTaskEither.match((l) { throw l; }, (metadataDataItem) { + logger.d( + 'Metadata tx id on _generateFileMetadataDataItem: ${metadataDataItem.id}'); metadata.setMetadataTxId = metadataDataItem.id; return metadataDataItem; }); @@ -791,6 +800,7 @@ Future _getDataItemResult({ return fileDataItemResult.match((l) { throw l; }, (r) { + logger.d('Data tx id: ${r.id}'); metadata.updateDataTxId(r.id); return r;