aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/src/net.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts
index 0e7dd29c2..9debdc57b 100644
--- a/editors/code/src/net.ts
+++ b/editors/code/src/net.ts
@@ -114,15 +114,16 @@ async function downloadFile(
114 114
115 log.debug("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath); 115 log.debug("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
116 116
117 let readBytes = 0;
118 res.body.on("data", (chunk: Buffer) => {
119 readBytes += chunk.length;
120 onProgress(readBytes, totalBytes);
121 });
122
123 // Put the artifact into a temporary folder to prevent partially downloaded files when user kills vscode 117 // Put the artifact into a temporary folder to prevent partially downloaded files when user kills vscode
124 await withTempFile(async tempFilePath => { 118 await withTempFile(async tempFilePath => {
125 const destFileStream = fs.createWriteStream(tempFilePath, { mode }); 119 const destFileStream = fs.createWriteStream(tempFilePath, { mode });
120
121 let readBytes = 0;
122 res.body.on("data", (chunk: Buffer) => {
123 readBytes += chunk.length;
124 onProgress(readBytes, totalBytes);
125 });
126
126 await pipeline(res.body, destFileStream); 127 await pipeline(res.body, destFileStream);
127 await new Promise<void>(resolve => { 128 await new Promise<void>(resolve => {
128 destFileStream.on("close", resolve); 129 destFileStream.on("close", resolve);