mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-24 05:40:29 -04: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:
@@ -67,7 +67,7 @@ export class JupyterServerInstallation {
|
||||
}
|
||||
|
||||
private async installDependencies(backgroundOperation: azdata.BackgroundOperation): Promise<void> {
|
||||
if (!fs.existsSync(this._pythonExecutable) || this._forceInstall || this._usingExistingPython) {
|
||||
if (!(await utils.exists(this._pythonExecutable)) || this._forceInstall || this._usingExistingPython) {
|
||||
window.showInformationMessage(msgInstallPkgStart);
|
||||
|
||||
this.outputChannel.show(true);
|
||||
@@ -180,11 +180,11 @@ export class JupyterServerInstallation {
|
||||
});
|
||||
|
||||
downloadRequest.pipe(fs.createWriteStream(pythonPackagePathLocal))
|
||||
.on('close', () => {
|
||||
.on('close', async () => {
|
||||
//unpack python zip/tar file
|
||||
this.outputChannel.appendLine(msgPythonUnpackPending);
|
||||
let pythonSourcePath = path.join(installPath, constants.pythonBundleVersion);
|
||||
if (!this._usingExistingPython && fs.existsSync(pythonSourcePath)) {
|
||||
if (!this._usingExistingPython && await utils.exists(pythonSourcePath)) {
|
||||
try {
|
||||
fs.removeSync(pythonSourcePath);
|
||||
} catch (err) {
|
||||
@@ -256,7 +256,7 @@ export class JupyterServerInstallation {
|
||||
}
|
||||
}
|
||||
|
||||
if (fs.existsSync(this._pythonExecutable)) {
|
||||
if (await utils.exists(this._pythonExecutable)) {
|
||||
let pythonUserDir = await this.getPythonUserDir(this._pythonExecutable);
|
||||
if (pythonUserDir) {
|
||||
this.pythonEnvVarPath = pythonUserDir + delimiter + this.pythonEnvVarPath;
|
||||
@@ -330,7 +330,7 @@ export class JupyterServerInstallation {
|
||||
await this.configurePackagePaths();
|
||||
};
|
||||
let installReady = new Deferred<void>();
|
||||
if (!fs.existsSync(this._pythonExecutable) || this._forceInstall || this._usingExistingPython) {
|
||||
if (!(await utils.exists(this._pythonExecutable)) || this._forceInstall || this._usingExistingPython) {
|
||||
this.apiWrapper.startBackgroundOperation({
|
||||
displayName: msgTaskName,
|
||||
description: msgTaskName,
|
||||
@@ -522,6 +522,7 @@ export class JupyterServerInstallation {
|
||||
}
|
||||
|
||||
let condaExePath = this.getCondaExePath();
|
||||
// tslint:disable-next-line:no-sync
|
||||
return fs.existsSync(condaExePath);
|
||||
}
|
||||
|
||||
@@ -538,6 +539,7 @@ export class JupyterServerInstallation {
|
||||
|
||||
let useExistingInstall = JupyterServerInstallation.getExistingPythonSetting(apiWrapper);
|
||||
let pythonExe = JupyterServerInstallation.getPythonExePath(pathSetting, useExistingInstall);
|
||||
// tslint:disable-next-line:no-sync
|
||||
return fs.existsSync(pythonExe);
|
||||
}
|
||||
|
||||
@@ -568,6 +570,7 @@ export class JupyterServerInstallation {
|
||||
let notebookConfig = apiWrapper.getConfiguration(constants.notebookConfigKey);
|
||||
if (notebookConfig) {
|
||||
let configPythonPath = notebookConfig[constants.pythonPathConfigKey];
|
||||
// tslint:disable-next-line:no-sync
|
||||
if (configPythonPath && fs.existsSync(configPythonPath)) {
|
||||
path = configPythonPath;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,13 @@ export class ServerInstanceUtils {
|
||||
public copy(src: string, dest: string): Promise<void> {
|
||||
return fs.copy(src, dest);
|
||||
}
|
||||
public existsSync(dirPath: string): boolean {
|
||||
return fs.existsSync(dirPath);
|
||||
public async exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(path);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public generateUuid(): string {
|
||||
return UUID.generateUuid();
|
||||
@@ -204,7 +209,7 @@ export class PerNotebookServerInstance implements IServerInstance {
|
||||
private async copyKernelsToSystemJupyterDirs(): Promise<void> {
|
||||
let kernelsExtensionSource = path.join(this.options.install.extensionPath, 'kernels');
|
||||
this._systemJupyterDir = path.join(this.getSystemJupyterHomeDir(), 'kernels');
|
||||
if (!this.utils.existsSync(this._systemJupyterDir)) {
|
||||
if (!(await this.utils.exists(this._systemJupyterDir))) {
|
||||
await this.utils.mkDir(this._systemJupyterDir, this.options.install.outputChannel);
|
||||
}
|
||||
await this.utils.copy(kernelsExtensionSource, this._systemJupyterDir);
|
||||
|
||||
Reference in New Issue
Block a user