Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 3ae2f4b

Browse files
committed
Fix: download error flow
1 parent f74cd4f commit 3ae2f4b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/service/async_task_service/quick_install.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@ export class QuickInstallTask extends AsyncTask {
3939

4040
private download(): Promise<boolean> {
4141
return new Promise(async (resolve, reject) => {
42-
this.zipPath = path.normalize(path.join(this.instance.config.cwd, this.TMP_ZIP_NAME));
43-
const writeStream = fs.createWriteStream(this.zipPath);
44-
const response = await axios<Readable>({
45-
url: this.targetLink,
46-
responseType: "stream"
47-
});
48-
this.downloadStream = pipeline(response.data, writeStream, (err) => {
49-
if (err) {
50-
reject(err);
51-
} else {
52-
resolve(true);
53-
}
54-
});
42+
try {
43+
this.zipPath = path.normalize(path.join(this.instance.config.cwd, this.TMP_ZIP_NAME));
44+
const writeStream = fs.createWriteStream(this.zipPath);
45+
const response = await axios<Readable>({
46+
url: this.targetLink,
47+
responseType: "stream"
48+
});
49+
this.downloadStream = pipeline(response.data, writeStream, (err) => {
50+
if (err) {
51+
reject(err);
52+
} else {
53+
resolve(true);
54+
}
55+
});
56+
} catch (error) {
57+
reject(error);
58+
}
5559
});
5660
}
5761

0 commit comments

Comments
 (0)