aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-06-24 23:00:30 +0100
committerVeetaha <[email protected]>2020-06-24 23:00:30 +0100
commitc1d39571c9ac27c80ca2c1feb5dd53fc6f325b34 (patch)
tree477bd524f272c387b0652863d44b67ff27094f68 /editors/code
parent62ebaa822b0770558ffc3b8fba291996e2c4a5b0 (diff)
Append 10 random hex chars to temp artifact files
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/net.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts
index 7c77530b8..866092882 100644
--- a/editors/code/src/net.ts
+++ b/editors/code/src/net.ts
@@ -1,8 +1,10 @@
1import fetch from "node-fetch"; 1import fetch from "node-fetch";
2import * as vscode from "vscode"; 2import * as vscode from "vscode";
3import * as stream from "stream"; 3import * as stream from "stream";
4import * as crypto from "crypto";
4import * as fs from "fs"; 5import * as fs from "fs";
5import * as util from "util"; 6import * as util from "util";
7import * as path from "path";
6import { log, assert } from "./util"; 8import { log, assert } from "./util";
7 9
8const pipeline = util.promisify(stream.pipeline); 10const pipeline = util.promisify(stream.pipeline);
@@ -68,7 +70,9 @@ interface DownloadOpts {
68export async function download(opts: DownloadOpts) { 70export async function download(opts: DownloadOpts) {
69 // Put artifact into a temporary file (in the same dir for simplicity) 71 // Put artifact into a temporary file (in the same dir for simplicity)
70 // to prevent partially downloaded files when user kills vscode 72 // to prevent partially downloaded files when user kills vscode
71 const tempFile = `${opts.dest}.tmp`; 73 const dest = path.parse(opts.dest);
74 const randomHex = crypto.randomBytes(5).toString("hex");
75 const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`);
72 76
73 await vscode.window.withProgress( 77 await vscode.window.withProgress(
74 { 78 {