Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 0a6b65e

Browse files
committed
Append 10 random hex chars to temp artifact files
1 parent 7fcecfa commit 0a6b65e

File tree

1 file changed

+5
-1
lines changed
  • rust-analyzer/editors/code/src

1 file changed

+5
-1
lines changed

rust-analyzer/editors/code/src/net.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import fetch from "node-fetch";
22
import * as vscode from "vscode";
33
import * as stream from "stream";
4+
import * as crypto from "crypto";
45
import * as fs from "fs";
56
import * as util from "util";
7+
import * as path from "path";
68
import { log, assert } from "./util";
79

810
const pipeline = util.promisify(stream.pipeline);
@@ -68,7 +70,9 @@ interface DownloadOpts {
6870
export async function download(opts: DownloadOpts) {
6971
// Put artifact into a temporary file (in the same dir for simplicity)
7072
// 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}`);
7276

7377
await vscode.window.withProgress(
7478
{

0 commit comments

Comments
 (0)