aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 5db66df93..6ed8b6146 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -157,7 +157,7 @@ async function bootstrap(config: Config, state: PersistentState): Promise<string
157 await fs.mkdir(config.globalStoragePath, { recursive: true }); 157 await fs.mkdir(config.globalStoragePath, { recursive: true });
158 158
159 if (config.package.releaseTag != NIGHTLY_TAG) { 159 if (config.package.releaseTag != NIGHTLY_TAG) {
160 await state.removeReleaseId(); 160 await state.removeNightlyReleaseId();
161 } 161 }
162 await bootstrapExtension(config, state); 162 await bootstrapExtension(config, state);
163 const path = await bootstrapServer(config, state); 163 const path = await bootstrapServer(config, state);
@@ -184,7 +184,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
184 const lastCheck = state.lastCheck; 184 const lastCheck = state.lastCheck;
185 185
186 const anHour = 60 * 60 * 1000; 186 const anHour = 60 * 60 * 1000;
187 const shouldCheckForNewNightly = state.releaseId === undefined || (now - (lastCheck ?? 0)) > anHour; 187 const shouldCheckForNewNightly = state.nightlyReleaseId === undefined || (now - (lastCheck ?? 0)) > anHour;
188 188
189 if (!shouldCheckForNewNightly) return; 189 if (!shouldCheckForNewNightly) return;
190 } 190 }
@@ -193,19 +193,18 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
193 return await fetchRelease("nightly", state.githubToken, config.httpProxy); 193 return await fetchRelease("nightly", state.githubToken, config.httpProxy);
194 }).catch(async (e) => { 194 }).catch(async (e) => {
195 log.error(e); 195 log.error(e);
196 if (state.releaseId === undefined) { // Show error only for the initial download 196 if (state.nightlyReleaseId === undefined) { // Show error only for the initial download
197 await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); 197 await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`);
198 } 198 }
199 return; 199 return;
200 }); 200 });
201 if (release === undefined) { 201 if (release === undefined) {
202 if (state.releaseId === undefined) { // Show error only for the initial download 202 if (state.nightlyReleaseId === undefined) { // Show error only for the initial download
203 await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); 203 await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned");
204 } 204 }
205 return; 205 return;
206 } 206 }
207 // If currently used extension is nightly and its release id matches the downloaded release id, we're already on the latest nightly version 207 if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.nightlyReleaseId) return;
208 if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.releaseId) return;
209 208
210 const userResponse = await vscode.window.showInformationMessage( 209 const userResponse = await vscode.window.showInformationMessage(
211 "New version of rust-analyzer (nightly) is available (requires reload).", 210 "New version of rust-analyzer (nightly) is available (requires reload).",
@@ -230,7 +229,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
230 await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest)); 229 await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest));
231 await fs.unlink(dest); 230 await fs.unlink(dest);
232 231
233 await state.updateReleaseId(release.id); 232 await state.updateNightlyReleaseId(release.id);
234 await state.updateLastCheck(now); 233 await state.updateLastCheck(now);
235 await vscode.commands.executeCommand("workbench.action.reloadWindow"); 234 await vscode.commands.executeCommand("workbench.action.reloadWindow");
236} 235}