Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit dca44cd

Browse files
fix: correct progress multi download (#938)
1 parent 795e636 commit dca44cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cortex-js/src/utils/download-progress.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Presets, SingleBar } from "cli-progress";
22
import { Cortex } from "@cortexso/cortex.js";
33
import { exit, stdin, stdout } from 'node:process';
4-
import { DownloadType } from "@/domain/models/download.interface";
4+
import { DownloadState, DownloadType } from "@/domain/models/download.interface";
55

66
export const downloadProgress = async (cortex: Cortex, downloadId?: string, downloadType?: DownloadType) => {
77
const response = await cortex.events.downloadEvent();
@@ -27,8 +27,9 @@ export const downloadProgress = async (cortex: Cortex, downloadId?: string, down
2727

2828
for await (const stream of response) {
2929
if (stream.length) {
30-
const data = stream[0] as any;
31-
if (downloadId && data.id !== downloadId || downloadType && data.type !== downloadType) continue;
30+
const data = (stream.find((data: any) => data.id === downloadId || !downloadId) as DownloadState | undefined);
31+
if (!data) continue;
32+
if (downloadType && data.type !== downloadType) continue;
3233

3334
if (data.status === 'downloaded') break;
3435

0 commit comments

Comments
 (0)