From c1d39571c9ac27c80ca2c1feb5dd53fc6f325b34 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Thu, 25 Jun 2020 01:00:30 +0300 Subject: Append 10 random hex chars to temp artifact files --- editors/code/src/net.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 @@ import fetch from "node-fetch"; import * as vscode from "vscode"; import * as stream from "stream"; +import * as crypto from "crypto"; import * as fs from "fs"; import * as util from "util"; +import * as path from "path"; import { log, assert } from "./util"; const pipeline = util.promisify(stream.pipeline); @@ -68,7 +70,9 @@ interface DownloadOpts { export async function download(opts: DownloadOpts) { // Put artifact into a temporary file (in the same dir for simplicity) // to prevent partially downloaded files when user kills vscode - const tempFile = `${opts.dest}.tmp`; + const dest = path.parse(opts.dest); + const randomHex = crypto.randomBytes(5).toString("hex"); + const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`); await vscode.window.withProgress( { -- cgit v1.2.3