avoid using XDG_RUNTIME_DIR on darwin (#175241)

fixes #168321
This commit is contained in:
João Moreno
2023-02-24 17:33:25 +01:00
committed by GitHub
parent cf4acb8050
commit 8635a5effd
2 changed files with 10 additions and 17 deletions

View File

@@ -17,7 +17,7 @@ function getIPCHandlePath(id: string): string {
return `\\\\.\\pipe\\vscode-git-${id}-sock`;
}
if (process.env['XDG_RUNTIME_DIR']) {
if (process.platform !== 'darwin' && process.env['XDG_RUNTIME_DIR']) {
return path.join(process.env['XDG_RUNTIME_DIR'] as string, `vscode-git-${id}.sock`);
}

View File

@@ -772,14 +772,10 @@ export function createRandomIPCHandle(): string {
return `\\\\.\\pipe\\vscode-ipc-${randomSuffix}-sock`;
}
// Mac/Unix: use socket file and prefer
// XDG_RUNTIME_DIR over tmpDir
let result: string;
if (XDG_RUNTIME_DIR) {
result = join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
} else {
result = join(getNodeDependencies().os.tmpdir(), `vscode-ipc-${randomSuffix}.sock`);
}
// Mac & Unix: Use socket file
// Unix: Prefer XDG_RUNTIME_DIR over user data path
const basePath = process.platform !== 'darwin' && XDG_RUNTIME_DIR ? XDG_RUNTIME_DIR : getNodeDependencies().os.tmpdir();
const result = join(basePath, `vscode-ipc-${randomSuffix}.sock`);
// Validate length
validateIPCHandleLength(result);
@@ -795,20 +791,17 @@ export function createStaticIPCHandle(directoryPath: string, type: string, versi
return `\\\\.\\pipe\\${scope}-${version}-${type}-sock`;
}
// Mac/Unix: use socket file and prefer
// XDG_RUNTIME_DIR over user data path
// unless portable
// Trim the version and type values for
// the socket to prevent too large
// file names causing issues:
// https://unix.stackexchange.com/questions/367008/why-is-socket-path-length-limited-to-a-hundred-chars
// Mac & Unix: Use socket file
// Unix: Prefer XDG_RUNTIME_DIR over user data path, unless portable
// Trim the version and type values for the socket to prevent too large
// file names causing issues: https://unix.stackexchange.com/q/367008
const versionForSocket = version.substr(0, 4);
const typeForSocket = type.substr(0, 6);
const scopeForSocket = scope.substr(0, 8);
let result: string;
if (XDG_RUNTIME_DIR && !process.env['VSCODE_PORTABLE']) {
if (process.platform !== 'darwin' && XDG_RUNTIME_DIR && !process.env['VSCODE_PORTABLE']) {
result = join(XDG_RUNTIME_DIR, `vscode-${scopeForSocket}-${versionForSocket}-${typeForSocket}.sock`);
} else {
result = join(directoryPath, `${versionForSocket}-${typeForSocket}.sock`);