From d13539eafd1343e2bd726702762208e02628e8a5 Mon Sep 17 00:00:00 2001 From: ido Date: Wed, 30 Oct 2024 21:50:04 +0200 Subject: [PATCH] fix(cli): close animation on error --- .../transfer-cli/cli-animation-wrapper.ts | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/download/transfer-visualize/transfer-cli/cli-animation-wrapper.ts b/src/download/transfer-visualize/transfer-cli/cli-animation-wrapper.ts index ce421af..d1a2c48 100644 --- a/src/download/transfer-visualize/transfer-cli/cli-animation-wrapper.ts +++ b/src/download/transfer-visualize/transfer-cli/cli-animation-wrapper.ts @@ -66,19 +66,24 @@ export default class CliAnimationWrapper { return; } this._activeCLI.loadingAnimation.start(); - const engine = await this._downloadEngine; - this._activeCLI.loadingAnimation.stop(); - engine.once("start", () => { - this._activeCLI?.start(); + try { + const engine = await this._downloadEngine; + this._activeCLI.loadingAnimation.stop(); - engine.on("progress", (progress) => { - this._activeCLI?.updateStatues(engine.downloadStatues, progress); - }); + engine.once("start", () => { + this._activeCLI?.start(); + + engine.on("progress", (progress) => { + this._activeCLI?.updateStatues(engine.downloadStatues, progress); + }); - engine.on("closed", () => { - this._activeCLI?.stop(); + engine.on("closed", () => { + this._activeCLI?.stop(); + }); }); - }); + } finally { + this._activeCLI.loadingAnimation.stop(); + } } }