Skip to content

Commit 089386f

Browse files
committed
fix #382 do not overwrite a deployed class
1 parent 191691d commit 089386f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/commands/compile.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ export async function checkChangedOnServer(file: CurrentFile, force = false): Pr
6767

6868
async function importFile(file: CurrentFile, ignoreConflict?: boolean): Promise<any> {
6969
const api = new AtelierAPI(file.uri);
70+
if (file.name.split(".").pop().toLowerCase() === "cls") {
71+
const result = await api.actionIndex([file.name]);
72+
if (result.result.content[0].content.depl) {
73+
vscode.window.showErrorMessage("Cannot import over a deployed class");
74+
return Promise.reject();
75+
}
76+
}
7077
const content = file.content.split(/\r?\n/);
7178
const mtime = await checkChangedOnServer(file);
7279
ignoreConflict = ignoreConflict || mtime < 0 || (file.uri.scheme === "file" && config("overwriteServerChanges"));

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
193193
// Weirdly, if the file exists on the server we don't actually write its content here.
194194
// Instead we simply return as though we wrote it successfully.
195195
// The actual writing is done by our workspace.onDidSaveTextDocument handler.
196+
// But first check a case for which we should fail the write and leave the document dirty if changed.
197+
if (fileName.split(".").pop().toLowerCase() === "cls") {
198+
return api.actionIndex([fileName]).then((result) => {
199+
if (result.result.content[0].content.depl) {
200+
throw new Error("Cannot overwrite a deployed class");
201+
}
202+
});
203+
}
196204
return;
197205
},
198206
(error) => {

0 commit comments

Comments
 (0)