Skip to content

Commit 77fa709

Browse files
committed
Second attempt to initialise when connect event fails
Signed-off-by: worksofliam <[email protected]>
1 parent 9ab82b8 commit 77fa709

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/connection/serverComponent.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,30 @@ export class ServerComponent {
6767
const instance = getInstance();
6868
const connection = instance.getConnection();
6969

70+
if (!connection) {
71+
return false;
72+
}
73+
74+
if (!Config.ready) {
75+
Config.setConnectionName(connection.currentConnectionName);
76+
}
77+
78+
if (!this.installed) {
79+
this.installed = await this.isAlreadyInstalled();
80+
}
81+
82+
return this.installed;
83+
}
84+
85+
static async isAlreadyInstalled() {
86+
const instance = getInstance();
87+
const connection = instance.getConnection();
88+
7089
const exists = await connection.sendCommand({
7190
command: `ls ${this.getComponentPath()}`
7291
});
7392

74-
this.installed = (exists.code === 0);
75-
76-
return this.installed;
93+
return (exists.code === 0);
7794
}
7895

7996
/**
@@ -88,16 +105,18 @@ export class ServerComponent {
88105

89106
try {
90107
const assetPath = path.join(extensionPath, `dist`, SERVER_VERSION_FILE);
91-
const assetExists = await exists(assetPath);
108+
const assetExistsLocally = await exists(assetPath);
92109

93-
ServerComponent.writeOutput(JSON.stringify({assetPath, assetExists}));
110+
ServerComponent.writeOutput(JSON.stringify({assetPath, assetExists: assetExistsLocally}));
94111

95-
if (assetExists) {
112+
if (assetExistsLocally) {
96113
const basename = SERVER_VERSION_FILE;
97114
const lastInstalledName = Config.getServerComponentName();
98115

99116
ServerComponent.writeOutput(JSON.stringify({basename, lastInstalledName}));
100117

118+
await this.initialise();
119+
101120
if (lastInstalledName !== basename || this.installed === false) {
102121
// This means we're currently running a different version,
103122
// or maybe not at all (currentlyInstalled can be undefined)

0 commit comments

Comments
 (0)