Move cancellation files to own dir

Fixes #53423
This commit is contained in:
Matt Bierner
2018-07-18 14:28:42 -07:00
parent a51874590c
commit 533c6deb79
2 changed files with 20 additions and 8 deletions

View File

@@ -974,7 +974,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
if (this.apiVersion.gte(API.v222)) {
this.cancellationPipeName = electron.getTempSock('tscancellation');
this.cancellationPipeName = electron.getTempFile('tscancellation');
args.push('--cancellationPipeName', this.cancellationPipeName + '*');
}

View File

@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import Logger from './logger';
import { getTempFile, makeRandomHexString } from './temp';
import * as temp from './temp';
import path = require('path');
import os = require('os');
import fs = require('fs');
import net = require('net');
import cp = require('child_process');
@@ -15,13 +15,25 @@ export interface IForkOptions {
execArgv?: string[];
}
export function getTempSock(prefix: string): string {
const fullName = `vscode-${prefix}-${makeRandomHexString(20)}`;
return getTempFile(fullName + '.sock');
const getRootTempDir = (() => {
let dir: string | undefined;
return () => {
if (!dir) {
dir = temp.getTempFile(`vscode-typescript`);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
}
return dir;
};
})();
export function getTempFile(prefix: string): string {
return path.join(getRootTempDir(), `${prefix}-${temp.makeRandomHexString(20)}.tmp`);
}
function generatePipeName(): string {
return getPipeName(makeRandomHexString(40));
return getPipeName(temp.makeRandomHexString(40));
}
function getPipeName(name: string): string {
@@ -31,7 +43,7 @@ function getPipeName(name: string): string {
}
// Mac/Unix: use socket file
return path.join(os.tmpdir(), fullName + '.sock');
return path.join(getRootTempDir(), fullName + '.sock');
}
function generatePatchedEnv(