diff options
author | Veetaha <[email protected]> | 2020-06-24 23:00:30 +0100 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-06-24 23:00:30 +0100 |
commit | c1d39571c9ac27c80ca2c1feb5dd53fc6f325b34 (patch) | |
tree | 477bd524f272c387b0652863d44b67ff27094f68 /editors/code | |
parent | 62ebaa822b0770558ffc3b8fba291996e2c4a5b0 (diff) |
Append 10 random hex chars to temp artifact files
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/net.ts | 6 |
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 @@ | |||
1 | import fetch from "node-fetch"; | 1 | import fetch from "node-fetch"; |
2 | import * as vscode from "vscode"; | 2 | import * as vscode from "vscode"; |
3 | import * as stream from "stream"; | 3 | import * as stream from "stream"; |
4 | import * as crypto from "crypto"; | ||
4 | import * as fs from "fs"; | 5 | import * as fs from "fs"; |
5 | import * as util from "util"; | 6 | import * as util from "util"; |
7 | import * as path from "path"; | ||
6 | import { log, assert } from "./util"; | 8 | import { log, assert } from "./util"; |
7 | 9 | ||
8 | const pipeline = util.promisify(stream.pipeline); | 10 | const pipeline = util.promisify(stream.pipeline); |
@@ -68,7 +70,9 @@ interface DownloadOpts { | |||
68 | export async function download(opts: DownloadOpts) { | 70 | export 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 | { |