Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
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
7 changes: 4 additions & 3 deletions cortex-js/src/utils/download-progress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Presets, SingleBar } from "cli-progress";
import { Cortex } from "@cortexso/cortex.js";
import { exit, stdin, stdout } from 'node:process';
import { DownloadType } from "@/domain/models/download.interface";
import { DownloadState, DownloadType } from "@/domain/models/download.interface";

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

for await (const stream of response) {
if (stream.length) {
const data = stream[0] as any;
if (downloadId && data.id !== downloadId || downloadType && data.type !== downloadType) continue;
const data = (stream.find((data: any) => data.id === downloadId || !downloadId) as DownloadState | undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why bitwise operator?

if (!data) continue;
if (downloadType && data.type !== downloadType) continue;

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

Expand Down