diff --git a/.changeset/slick-dots-obey.md b/.changeset/slick-dots-obey.md
new file mode 100644
index 0000000000..c3254fdbe5
--- /dev/null
+++ b/.changeset/slick-dots-obey.md
@@ -0,0 +1,5 @@
+---
+'@milaboratories/pl-drivers': patch
+---
+
+drivers: download: fix big files downloading
diff --git a/etc/blocks/download-file/model/src/index.ts b/etc/blocks/download-file/model/src/index.ts
index da1c7c1565..398883d0bb 100644
--- a/etc/blocks/download-file/model/src/index.ts
+++ b/etc/blocks/download-file/model/src/index.ts
@@ -34,15 +34,18 @@ export const platforma = BlockModel.create('Heavy')
inputHandle: undefined
})
- .output('blob', getResourceValueAsJson()(getResourceField(MainOutputs, 'blob')))
+ // .output('blob', getResourceValueAsJson()(getResourceField(MainOutputs, 'blob')))
.output('handle', getImportProgress(getResourceField(MainOutputs, 'handle')))
- .output('content', getBlobContent(getResourceField(MainOutputs, 'downloadable')))
+
+ // .output('content', getBlobContent(getResourceField(MainOutputs, 'downloadable')))
- .output('contentAsString', getBlobContentAsString(getResourceField(MainOutputs, 'downloadable')))
+ .output('content', getBlobContent(getResourceField(MainOutputs, 'downloadable'), {from: 0, to: 10}))
- .output('contentAsString1', (ctx) =>
+ // .output('contentAsString', getBlobContentAsString(getResourceField(MainOutputs, 'downloadable')))
+
+/* .output('contentAsString1', (ctx) =>
ctx.outputs
?.resolve('downloadable')
?.getFileContentAsString()
@@ -63,17 +66,18 @@ export const platforma = BlockModel.create('Heavy')
'downloadedBlobContent',
getDownloadedBlobContent(getResourceField(MainOutputs, 'downloadable'))
)
-
+*/
.output(
'onDemandBlobContent',
getOnDemandBlobContent(getResourceField(MainOutputs, 'downloadable'))
)
+ /*
.output(
'onDemandBlobContent1',
(ctx) => ctx.outputs?.resolve('downloadable')?.getRemoteFileHandle()
)
-
+ */
.output('getFileHandle', (ctx) => ctx.outputs?.resolve('downloadable')?.getFileHandle())
.sections((ctx) => {
diff --git a/etc/blocks/download-file/ui/src/MainPage.vue b/etc/blocks/download-file/ui/src/MainPage.vue
index 95b796a185..295cf12807 100644
--- a/etc/blocks/download-file/ui/src/MainPage.vue
+++ b/etc/blocks/download-file/ui/src/MainPage.vue
@@ -19,6 +19,15 @@ const progress = computed(() => {
return handle.value;
})
+const strContent = computed(() => {
+ const content = app.snapshot.outputs.content;
+ if (!content || !content.ok) {
+ return undefined;
+ }
+ return new TextDecoder().decode(content.value);
+})
+
+/*
const onDemandContent = computedAsync(async () => {
const handle = app.snapshot.outputs.onDemandBlobContent;
if (!handle) {
@@ -99,7 +108,7 @@ const onDemandRangeContent1 = computedAsync(async () => {
return new TextDecoder().decode(content);
})
-
+ */
@@ -108,15 +117,15 @@ const onDemandRangeContent1 = computedAsync(async () => {
File content:
- {{ app.model.outputs.content }}
+ {{ strContent }}
-
+
-
+
-
+
diff --git a/lib/node/pl-drivers/src/drivers/download_blob/download_blob_task.ts b/lib/node/pl-drivers/src/drivers/download_blob/download_blob_task.ts
index d82950db92..055e8fce49 100644
--- a/lib/node/pl-drivers/src/drivers/download_blob/download_blob_task.ts
+++ b/lib/node/pl-drivers/src/drivers/download_blob/download_blob_task.ts
@@ -73,7 +73,12 @@ export class DownloadBlobTask {
}
}
- private async ensureDownloaded() {
+ /**
+ * If the blob is downloaded, just returns it's size.
+ * If the blob is not downloaded, downloads it, writes it to the disk atomically and returns the size.
+ * Has a signal to cancel the task and a state to print it if something goes wrong.
+ */
+ private async ensureDownloaded(): Promise {
this.signalCtl.signal.throwIfAborted();
this.state = {};