From 2b8508574d5fbd7b58ad4f967e1a4aebf24b120a Mon Sep 17 00:00:00 2001 From: Amir Omidi Date: Wed, 2 Oct 2019 12:57:29 -0700 Subject: [PATCH] Create the azure folder differently. (#7470) Create the folder with a different mechanism. --- extensions/azurecore/src/extension.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts index 0946a88979..feef12577a 100644 --- a/extensions/azurecore/src/extension.ts +++ b/extensions/azurecore/src/extension.ts @@ -84,15 +84,29 @@ export async function activate(context: vscode.ExtensionContext) { // Create the folder for storing the token caches async function findOrMakeStoragePath() { - let storagePath = path.join(getDefaultLogLocation(), constants.extensionName); + let defaultLogLocation = getDefaultLogLocation(); + let storagePath = path.join(defaultLogLocation, constants.extensionName); + + try { + await fs.mkdir(defaultLogLocation, { recursive: true }); + } catch (e) { + if (e.code !== 'EEXIST') { + console.log(`Creating the base directory failed... ${e}`); + return undefined; + } + } + try { await fs.mkdir(storagePath, { recursive: true }); - console.log('Initialized Azure account extension storage.'); - } - catch (e) { - console.error(`Initialization of Azure account extension storage failed: ${e}`); - console.error('Azure accounts will not be available'); + } catch (e) { + if (e.code !== 'EEXIST') { + console.error(`Initialization of Azure account extension storage failed: ${e}`); + console.error('Azure accounts will not be available'); + return undefined; + } } + + console.log('Initialized Azure account extension storage.'); return storagePath; }