sync delete files
This commit is contained in:
Родитель
33c5d42f3c
Коммит
3651e4617d
|
@ -13,7 +13,7 @@ import { TelemetryWrapper } from "vscode-extension-telemetry-wrapper";
|
|||
import { AzureAccount, CloudShell } from "./azure-account.api";
|
||||
import { BaseShell } from "./baseShell";
|
||||
import { aciConfig, Constants, exportContainerCmd, exportTestScript } from "./constants";
|
||||
import { azFilePush, escapeFile, TerraformCommand, TestOption } from "./shared";
|
||||
import { azFileDelete, azFilePush, escapeFile, TerraformCommand, TestOption } from "./shared";
|
||||
import { terraformChannel } from "./terraformChannel";
|
||||
import { getStorageAccountforCloudShell, IStorageAccount } from "./utils/cloudShellUtils";
|
||||
import * as settingUtils from "./utils/settingUtils";
|
||||
|
@ -47,6 +47,32 @@ export class AzureCloudShell extends BaseShell {
|
|||
}
|
||||
}
|
||||
|
||||
public async deleteFiles(files: vscode.Uri[]): Promise<void> {
|
||||
const RETRY_TIMES = 3;
|
||||
|
||||
if (!await this.connectedToCloudShell()) {
|
||||
terraformChannel.appendLine(`cloud shell can not be opened, file deleting operation is not synced`);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const file of files.map((a) => a.fsPath)) {
|
||||
for (let i = 0; i < RETRY_TIMES; i++) {
|
||||
try {
|
||||
terraformChannel.appendLine(`Deleting file ${file} from cloud shell`);
|
||||
await azFileDelete(
|
||||
vscode.workspace.getWorkspaceFolder(vscode.Uri.file(file)).name,
|
||||
this.storageAccountName,
|
||||
this.storageAccountKey,
|
||||
this.fileShareName,
|
||||
file);
|
||||
break;
|
||||
} catch (err) {
|
||||
terraformChannel.appendLine(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async runTerraformTests(testType: string, workingDirectory: string) {
|
||||
if (await this.connectedToCloudShell()) {
|
||||
|
||||
|
|
|
@ -16,9 +16,12 @@ import { checkTerraformInstalled } from "./utils/terraformUtils";
|
|||
import { DialogOption } from "./utils/uiUtils";
|
||||
import { selectWorkspaceFolder } from "./utils/workspaceUtils";
|
||||
|
||||
let fileWatcher: vscode.FileSystemWatcher;
|
||||
|
||||
export async function activate(ctx: vscode.ExtensionContext) {
|
||||
await checkTerraformInstalled();
|
||||
await TelemetryWrapper.initilizeFromJsonFile(ctx.asAbsolutePath("./package.json"));
|
||||
initFileWatcher(ctx);
|
||||
|
||||
ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.init", () => {
|
||||
terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Init);
|
||||
|
@ -88,4 +91,18 @@ export async function activate(ctx: vscode.ExtensionContext) {
|
|||
|
||||
export function deactivate(): void {
|
||||
terraformShellManager.dispose();
|
||||
if (fileWatcher) {
|
||||
fileWatcher.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
function initFileWatcher(ctx: vscode.ExtensionContext): void {
|
||||
fileWatcher = vscode.workspace.createFileSystemWatcher(getSyncFileBlobPattern());
|
||||
ctx.subscriptions.push(
|
||||
fileWatcher.onDidDelete((deletedUri) => {
|
||||
if (isTerminalSetToCloudShell()) {
|
||||
terraformShellManager.getCloudShell().deleteFiles([deletedUri]);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче