Skip to content

Commit

Permalink
fix(cli): format ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Sep 22, 2024
1 parent d8d504d commit 66d2d59
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export default class DownloadEngineFile extends EventEmitter<DownloadEngineFileE
public async close() {
if (this._closed) return;
if (this._downloadStatus !== DownloadStatus.Finished) {
this._progressStatus.finished();
this._downloadStatus = DownloadStatus.Cancelled;
this._sendProgressDownloadPart();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {BaseMultiProgressBar, CLIProgressPrintType} from "./BaseMultiProgressBar.js";
import {FormattedStatus} from "../../format-transfer-status.js";
import {DownloadStatus} from "../../../download-engine/download-file/progress-status-file.js";
import {DownloadFlags, DownloadStatus} from "../../../download-engine/download-file/progress-status-file.js";

export class SummaryMultiProgressBar extends BaseMultiProgressBar {
public override readonly printType: CLIProgressPrintType = "update";
Expand All @@ -9,6 +9,9 @@ export class SummaryMultiProgressBar extends BaseMultiProgressBar {
private _lastStatuses: FormattedStatus[] = [];

override createMultiProgressBar(statuses: FormattedStatus[], oneStatus: FormattedStatus) {
oneStatus = structuredClone(oneStatus);
oneStatus.downloadFlags.push(DownloadFlags.DownloadSequence);

const linesToPrint: FormattedStatus[] = [];

let index = 0;
Expand All @@ -28,7 +31,9 @@ export class SummaryMultiProgressBar extends BaseMultiProgressBar {
const {allStatusesSorted} = this.recorderStatusByImportance(linesToPrint);
const filterStatusesSliced = allStatusesSorted.slice(0, this.options.maxViewDownloads);

filterStatusesSliced.push(oneStatus);
if (statuses.length > 1 || oneStatus.downloadStatus === DownloadStatus.Active) {
filterStatusesSliced.push(oneStatus);
}

const activeDownloads = statuses.filter((status) => status.downloadStatus === DownloadStatus.Active).length;
this._parallelDownloads ||= activeDownloads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class BaseTransferCliProgressBar implements TransferCliProgressBa
{
type: "speed",
fullText: formattedSpeed,
size: "00.00kB/s".length
size: Math.max("00.00kB/s".length, formattedSpeed.length)
},
...this.getETA()
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class FancyTransferCliProgressBar extends BaseTransferCliProgress
}, {
type: "speed",
fullText: formattedSpeed,
size: "00.00kB/s".length
size: Math.max("00.00kB/s".length, formattedSpeed.length)
}, ...this.getETA(" ")]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class SummaryTransferCliProgressBar extends FancyTransferCliProgr

protected renderDownloadSequence(): string {
const {formatTransferredOfTotal, formattedSpeed, formatTimeLeft, comment, formattedPercentage} = this.status;
const progressBar = `(${formatTransferredOfTotal})`;
const dataLine: DataLine = [
{
type: "status",
Expand Down Expand Up @@ -78,8 +79,8 @@ export default class SummaryTransferCliProgressBar extends FancyTransferCliProgr
},
{
type: "progressBar",
fullText: `(${formatTransferredOfTotal})`,
size: 19,
fullText: progressBar,
size: progressBar.length,
formatter: (text) => text
},
{
Expand Down

0 comments on commit 66d2d59

Please sign in to comment.