Archived
1
0

Fix update check

This commit is contained in:
Asher 2019-10-30 17:35:50 -05:00
parent 3d5db8313a
commit fc3acfabb2
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -37,6 +37,9 @@ export class UpdateService extends AbstractUpdateService {
super(null, configurationService, environmentService, requestService, logService); super(null, configurationService, environmentService, requestService, logService);
} }
/**
* Return true if the currently installed version is the latest.
*/
public async isLatestVersion(latest?: IUpdate | null): Promise<boolean | undefined> { public async isLatestVersion(latest?: IUpdate | null): Promise<boolean | undefined> {
if (!latest) { if (!latest) {
latest = await this.getLatestVersion(); latest = await this.getLatestVersion();
@ -44,8 +47,12 @@ export class UpdateService extends AbstractUpdateService {
if (latest) { if (latest) {
const latestMajor = parseInt(latest.name); const latestMajor = parseInt(latest.name);
const currentMajor = parseInt(product.codeServerVersion); const currentMajor = parseInt(product.codeServerVersion);
return !isNaN(latestMajor) && !isNaN(currentMajor) && // If these are invalid versions we can't compare meaningfully.
currentMajor <= latestMajor && latest.name === product.codeServerVersion; return isNaN(latestMajor) || isNaN(currentMajor) ||
// This can happen when there is a pre-release for a new major version.
currentMajor > latestMajor ||
// Otherwise assume that if it's not the same then we're out of date.
latest.name === product.codeServerVersion;
} }
return true; return true;
} }
@ -62,7 +69,7 @@ export class UpdateService extends AbstractUpdateService {
this.setState(State.CheckingForUpdates(context)); this.setState(State.CheckingForUpdates(context));
try { try {
const update = await this.getLatestVersion(); const update = await this.getLatestVersion();
if (!update || this.isLatestVersion(update)) { if (!update || await this.isLatestVersion(update)) {
this.setState(State.Idle(UpdateType.Archive)); this.setState(State.Idle(UpdateType.Archive));
} else { } else {
this.setState(State.AvailableForDownload({ this.setState(State.AvailableForDownload({