diff options
author | wxb1ank <[email protected]> | 2021-06-15 18:29:02 +0100 |
---|---|---|
committer | wxb1ank <[email protected]> | 2021-06-15 18:29:02 +0100 |
commit | 56e128a979082de4ea58b7739049405fbc43f394 (patch) | |
tree | 5f85baa3fc4c36162ff2ea3011b796bf6ff56bf2 /editors/code/src/net.ts | |
parent | 7a8a72c38f5626aea6c8f3c2dacbb23ed166901e (diff) |
fix: clean-up #8951
Diffstat (limited to 'editors/code/src/net.ts')
-rw-r--r-- | editors/code/src/net.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 5c48c74e8..722dab756 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts | |||
@@ -91,7 +91,7 @@ export async function download(opts: DownloadOpts) { | |||
91 | // to prevent partially downloaded files when user kills vscode | 91 | // to prevent partially downloaded files when user kills vscode |
92 | // This also avoids overwriting running executables | 92 | // This also avoids overwriting running executables |
93 | const randomHex = crypto.randomBytes(5).toString("hex"); | 93 | const randomHex = crypto.randomBytes(5).toString("hex"); |
94 | const rawDest = path.parse(opts.dest.path); | 94 | const rawDest = path.parse(opts.dest.fsPath); |
95 | const tempFilePath = vscode.Uri.joinPath(vscode.Uri.file(rawDest.dir), `${rawDest.name}${randomHex}`); | 95 | const tempFilePath = vscode.Uri.joinPath(vscode.Uri.file(rawDest.dir), `${rawDest.name}${randomHex}`); |
96 | 96 | ||
97 | await vscode.window.withProgress( | 97 | await vscode.window.withProgress( |
@@ -116,7 +116,7 @@ export async function download(opts: DownloadOpts) { | |||
116 | } | 116 | } |
117 | ); | 117 | ); |
118 | 118 | ||
119 | await vscode.workspace.fs.rename(tempFilePath, opts.dest); | 119 | await vscode.workspace.fs.rename(tempFilePath, opts.dest, { overwrite: true }); |
120 | } | 120 | } |
121 | 121 | ||
122 | async function downloadFile( | 122 | async function downloadFile( |
@@ -148,7 +148,7 @@ async function downloadFile( | |||
148 | const totalBytes = Number(res.headers.get('content-length')); | 148 | const totalBytes = Number(res.headers.get('content-length')); |
149 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); | 149 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); |
150 | 150 | ||
151 | log.debug("Downloading file of", totalBytes, "bytes size from", urlString, "to", destFilePath.path); | 151 | log.debug("Downloading file of", totalBytes, "bytes size from", urlString, "to", destFilePath.fsPath); |
152 | 152 | ||
153 | let readBytes = 0; | 153 | let readBytes = 0; |
154 | res.body.on("data", (chunk: Buffer) => { | 154 | res.body.on("data", (chunk: Buffer) => { |
@@ -156,7 +156,7 @@ async function downloadFile( | |||
156 | onProgress(readBytes, totalBytes); | 156 | onProgress(readBytes, totalBytes); |
157 | }); | 157 | }); |
158 | 158 | ||
159 | const destFileStream = fs.createWriteStream(destFilePath.path, { mode }); | 159 | const destFileStream = fs.createWriteStream(destFilePath.fsPath, { mode }); |
160 | const srcStream = gunzip ? res.body.pipe(zlib.createGunzip()) : res.body; | 160 | const srcStream = gunzip ? res.body.pipe(zlib.createGunzip()) : res.body; |
161 | 161 | ||
162 | await pipeline(srcStream, destFileStream); | 162 | await pipeline(srcStream, destFileStream); |