Check major version when getting latest version

This commit is contained in:
Asher 2019-10-08 16:23:39 -05:00
parent e1e3f32643
commit ea9c511db8
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -37,9 +37,17 @@ export class UpdateService extends AbstractUpdateService {
super(null, configurationService, environmentService, requestService, logService); super(null, configurationService, environmentService, requestService, logService);
} }
public async isLatestVersion(): Promise<boolean | undefined> { public async isLatestVersion(latest?: IUpdate | null): Promise<boolean | undefined> {
const latest = await this.getLatestVersion(); if (!latest) {
return !latest || latest.name === pkg.codeServerVersion; latest = await this.getLatestVersion();
}
if (latest) {
const latestMajor = parseInt(latest.name);
const currentMajor = parseInt(pkg.codeServerVersion);
return !isNaN(latestMajor) && !isNaN(currentMajor) &&
currentMajor <= latestMajor && latest.name === pkg.codeServerVersion;
}
return true;
} }
protected buildUpdateFeedUrl(): string { protected buildUpdateFeedUrl(): string {
@ -57,7 +65,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 || !update.name || update.name === pkg.codeServerVersion) { if (!update || 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({