提交 533c6deb 编写于 作者: M Matt Bierner

Move cancellation files to own dir

Fixes #53423
上级 a5187459
...@@ -974,7 +974,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient ...@@ -974,7 +974,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
} }
if (this.apiVersion.gte(API.v222)) { if (this.apiVersion.gte(API.v222)) {
this.cancellationPipeName = electron.getTempSock('tscancellation'); this.cancellationPipeName = electron.getTempFile('tscancellation');
args.push('--cancellationPipeName', this.cancellationPipeName + '*'); args.push('--cancellationPipeName', this.cancellationPipeName + '*');
} }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import Logger from './logger'; import Logger from './logger';
import { getTempFile, makeRandomHexString } from './temp'; import * as temp from './temp';
import path = require('path'); import path = require('path');
import os = require('os'); import fs = require('fs');
import net = require('net'); import net = require('net');
import cp = require('child_process'); import cp = require('child_process');
...@@ -15,13 +15,25 @@ export interface IForkOptions { ...@@ -15,13 +15,25 @@ export interface IForkOptions {
execArgv?: string[]; execArgv?: string[];
} }
export function getTempSock(prefix: string): string { const getRootTempDir = (() => {
const fullName = `vscode-${prefix}-${makeRandomHexString(20)}`; let dir: string | undefined;
return getTempFile(fullName + '.sock'); 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 { function generatePipeName(): string {
return getPipeName(makeRandomHexString(40)); return getPipeName(temp.makeRandomHexString(40));
} }
function getPipeName(name: string): string { function getPipeName(name: string): string {
...@@ -31,7 +43,7 @@ function getPipeName(name: string): string { ...@@ -31,7 +43,7 @@ function getPipeName(name: string): string {
} }
// Mac/Unix: use socket file // Mac/Unix: use socket file
return path.join(os.tmpdir(), fullName + '.sock'); return path.join(getRootTempDir(), fullName + '.sock');
} }
function generatePatchedEnv( function generatePatchedEnv(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册