mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Move unlink on download into download function
Since this is required by all callsites its easier to have it in the function itself.
This commit is contained in:
parent
df4d59512e
commit
c7f4647749
2 changed files with 11 additions and 11 deletions
|
@ -76,6 +76,7 @@ interface DownloadOpts {
|
|||
dest: string;
|
||||
mode?: number;
|
||||
gunzip?: boolean;
|
||||
overwrite?: boolean,
|
||||
}
|
||||
|
||||
export async function download(opts: DownloadOpts) {
|
||||
|
@ -85,6 +86,13 @@ export async function download(opts: DownloadOpts) {
|
|||
const randomHex = crypto.randomBytes(5).toString("hex");
|
||||
const tempFile = path.join(dest.dir, `${dest.name}${randomHex}`);
|
||||
|
||||
if (opts.overwrite) {
|
||||
// Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
|
||||
await fs.promises.unlink(opts.dest).catch(err => {
|
||||
if (err.code !== "ENOENT") throw err;
|
||||
});
|
||||
}
|
||||
|
||||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue