From 9ff29d17fb36c7efdf96f068d9fc9fb0da76a15f Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 7 May 2021 11:34:39 -0500 Subject: [PATCH] Make sure directories exist Fixes #3040. --- lib/vscode/src/vs/server/node/server.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/vscode/src/vs/server/node/server.ts b/lib/vscode/src/vs/server/node/server.ts index a3708045d..1d5de6903 100644 --- a/lib/vscode/src/vs/server/node/server.ts +++ b/lib/vscode/src/vs/server/node/server.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs'; +import { promises as fs } from 'fs'; import * as net from 'net'; import { hostname, release } from 'os'; import * as path from 'path'; @@ -213,8 +213,18 @@ export class Vscode { private async initializeServices(args: NativeParsedArgs): Promise { const productService = { _serviceBrand: undefined, ...product }; const environmentService = new NativeEnvironmentService(args, productService); - // https://github.com/cdr/code-server/issues/1693 - fs.mkdirSync(environmentService.globalStorageHome.fsPath, { recursive: true }); + + await Promise.all([ + environmentService.extensionsPath, + environmentService.logsPath, + environmentService.globalStorageHome.fsPath, + environmentService.workspaceStorageHome.fsPath, + ...environmentService.extraExtensionPaths, + ...environmentService.extraBuiltinExtensionPaths, + ].map((p) => fs.mkdir(p, { recursive: true }).catch((error) => { + logger.warn(error.message || error); + }))); + const logService = new MultiplexLogService([ new ConsoleLogger(getLogLevel(environmentService)), new SpdLogLogger(RemoteExtensionLogFileName, path.join(environmentService.logsPath, `${RemoteExtensionLogFileName}.log`), false, getLogLevel(environmentService))