aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-06-22 17:50:57 +0100
committerVeetaha <[email protected]>2020-06-22 17:50:57 +0100
commit2d32e97cf94ce34e4cb3465c4f5de7b6574f54b5 (patch)
tree0a2526a9ef912a1b3aa007f4f2072b2565026ed6
parenteabbeec14c6624fb93344c25ecd79fe61972abbc (diff)
Hotfix skipping the first chunks of the artifacts
-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);