From 230ed3304a8acc84ffab36dd9e6d0ebc0f4d054d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 11:51:35 +0300 Subject: Better releaseId naming --- editors/code/src/main.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'editors/code/src/main.ts') 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 anHour; + const shouldCheckForNewNightly = state.nightlyReleaseId === undefined || (now - (lastCheck ?? 0)) > anHour; if (!shouldCheckForNewNightly) return; } @@ -193,19 +193,18 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi return await fetchRelease("nightly", state.githubToken, config.httpProxy); }).catch(async (e) => { log.error(e); - if (state.releaseId === undefined) { // Show error only for the initial download + if (state.nightlyReleaseId === undefined) { // Show error only for the initial download await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); } return; }); if (release === undefined) { - if (state.releaseId === undefined) { // Show error only for the initial download + if (state.nightlyReleaseId === undefined) { // Show error only for the initial download await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); } return; } - // If currently used extension is nightly and its release id matches the downloaded release id, we're already on the latest nightly version - if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.releaseId) return; + if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.nightlyReleaseId) return; const userResponse = await vscode.window.showInformationMessage( "New version of rust-analyzer (nightly) is available (requires reload).", @@ -230,7 +229,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest)); await fs.unlink(dest); - await state.updateReleaseId(release.id); + await state.updateNightlyReleaseId(release.id); await state.updateLastCheck(now); await vscode.commands.executeCommand("workbench.action.reloadWindow"); } -- cgit v1.2.3