Skip to content

Commit 9256b65

Browse files
authored
Fall back to Index for deployed check if query fails (#1083)
1 parent 271cd40 commit 9256b65

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/utils/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,11 +604,14 @@ export async function fileExists(file: vscode.Uri): Promise<boolean> {
604604

605605
/** Check if class `cls` is Deployed in using server connection `api`. */
606606
export async function isClassDeployed(cls: string, api: AtelierAPI): Promise<boolean> {
607-
return api
608-
.actionQuery("SELECT Deployed FROM %Dictionary.ClassDefinition WHERE Name = ?", [
609-
cls.slice(-4).toLowerCase() == ".cls" ? cls.slice(0, -4) : cls,
610-
])
611-
.then((data) => data.result.content[0]?.Deployed > 0);
607+
const clsname = cls.slice(-4).toLowerCase() == ".cls" ? cls.slice(0, -4) : cls;
608+
return (
609+
api
610+
.actionQuery("SELECT Deployed FROM %Dictionary.ClassDefinition WHERE Name = ?", [clsname])
611+
.then((data) => data.result.content[0]?.Deployed > 0)
612+
// Query failure is probably due to a permissions error, so fall back to index
613+
.catch(() => api.actionIndex([`${clsname}.cls`]).then((data) => data.result.content[0].content?.depl ?? false))
614+
);
612615
}
613616

614617
// ---------------------------------------------------------------------

0 commit comments

Comments
 (0)