mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Implement a no sync rule (#7216)
* implement a no sync rule * fix linting disable * fix unused imports * exclude more testing * clean up fs usage * clean up more fs usage * remove duplicate of code * fix compile errors
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import * as constants from './constants';
|
||||
@@ -54,12 +54,12 @@ function pushDisposable(disposable: vscode.Disposable): void {
|
||||
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
extensionContext = context;
|
||||
const apiWrapper = new ApiWrapper();
|
||||
let appContext = new AppContext(extensionContext, apiWrapper);
|
||||
|
||||
let storagePath = findOrMakeStoragePath();
|
||||
let storagePath = await findOrMakeStoragePath();
|
||||
if (!storagePath) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -82,12 +82,21 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
};
|
||||
}
|
||||
|
||||
async function exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(path);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the folder for storing the token caches
|
||||
function findOrMakeStoragePath() {
|
||||
async function findOrMakeStoragePath() {
|
||||
let storagePath = path.join(getDefaultLogLocation(), constants.extensionName);
|
||||
try {
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
fs.mkdirSync(storagePath);
|
||||
if (!(await exists(storagePath))) {
|
||||
await fs.mkdir(storagePath);
|
||||
console.log('Initialized Azure account extension storage.');
|
||||
}
|
||||
}
|
||||
@@ -124,4 +133,3 @@ function registerCommands(appContext: AppContext, azureResourceTree: AzureResour
|
||||
|
||||
registerAzureResourceDatabaseCommands(appContext);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user