about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorVeetaha <veetaha2@gmail.com>2020-06-22 19:50:57 +0300
committerVeetaha <veetaha2@gmail.com>2020-06-22 19:50:57 +0300
commit2d32e97cf94ce34e4cb3465c4f5de7b6574f54b5 (patch)
tree0a2526a9ef912a1b3aa007f4f2072b2565026ed6 /editors/code/src
parenteabbeec14c6624fb93344c25ecd79fe61972abbc (diff)
downloadrust-2d32e97cf94ce34e4cb3465c4f5de7b6574f54b5.tar.gz
rust-2d32e97cf94ce34e4cb3465c4f5de7b6574f54b5.zip
Hotfix skipping the first chunks of the artifacts
Diffstat (limited to 'editors/code/src')
-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 0e7dd29c264..9debdc57bfa 100644
--- a/editors/code/src/net.ts
+++ b/editors/code/src/net.ts
@@ -114,15 +114,16 @@ async function downloadFile(
 
     log.debug("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath);
 
-    let readBytes = 0;
-    res.body.on("data", (chunk: Buffer) => {
-        readBytes += chunk.length;
-        onProgress(readBytes, totalBytes);
-    });
-
     // Put the artifact into a temporary folder to prevent partially downloaded files when user kills vscode
     await withTempFile(async tempFilePath => {
         const destFileStream = fs.createWriteStream(tempFilePath, { mode });
+
+        let readBytes = 0;
+        res.body.on("data", (chunk: Buffer) => {
+            readBytes += chunk.length;
+            onProgress(readBytes, totalBytes);
+        });
+
         await pipeline(res.body, destFileStream);
         await new Promise<void>(resolve => {
             destFileStream.on("close", resolve);