fix(update): correct comparison [skip ci]

This commit is contained in:
Baptiste Augrain
2025-01-25 14:15:35 +01:00
parent 5094d6d12d
commit 94187707d3

View File

@@ -67,7 +67,7 @@ index 48638aa..8f738e7 100644
+ } + }
} }
diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts
index d3f27d3..4622c99 100644 index d3f27d3..8454ff3 100644
--- a/src/vs/platform/update/electron-main/updateService.darwin.ts --- a/src/vs/platform/update/electron-main/updateService.darwin.ts
+++ b/src/vs/platform/update/electron-main/updateService.darwin.ts +++ b/src/vs/platform/update/electron-main/updateService.darwin.ts
@@ -15,3 +15,3 @@ import { ILogService } from '../../log/common/log.js'; @@ -15,3 +15,3 @@ import { ILogService } from '../../log/common/log.js';
@@ -91,7 +91,7 @@ index d3f27d3..4622c99 100644
- const url = createUpdateURL(assetID, quality, this.productService); - const url = createUpdateURL(assetID, quality, this.productService);
+ const url = createUpdateURL(this.productService, quality, process.platform, process.arch); + const url = createUpdateURL(this.productService, quality, process.platform, process.arch);
try { try {
@@ -94,4 +90,23 @@ export class DarwinUpdateService extends AbstractUpdateService implements IRelau @@ -94,4 +90,29 @@ export class DarwinUpdateService extends AbstractUpdateService implements IRelau
protected doCheckForUpdates(context: any): void { protected doCheckForUpdates(context: any): void {
+ if (!this.url) { + if (!this.url) {
+ return; + return;
@@ -105,8 +105,14 @@ index d3f27d3..4622c99 100644
+ .then(update => { + .then(update => {
+ if (!update || !update.url || !update.version || !update.productVersion) { + if (!update || !update.url || !update.version || !update.productVersion) {
+ this.setState(State.Idle(UpdateType.Setup)); + this.setState(State.Idle(UpdateType.Setup));
+
+ return Promise.resolve(null);
+ } + }
+ else if(semver.compareBuild(update.productVersion.replace(/(\d+\.\d+\.\d+)(?:\.(\d+))(?:\-\w+)?/, '$1+$2'), `${this.productService.version}+${this.productService.release}`) >= 0) { +
+ const fetchedVersion = update.productVersion.replace(/(\d+\.\d+\.\d+)(?:\.(\d+))(\-\w+)?/, '$1$3+$2');
+ const currentVersion = `${this.productService.version}+${this.productService.release}`;
+
+ if(semver.compareBuild(currentVersion, fetchedVersion) >= 0) {
+ this.setState(State.Idle(UpdateType.Setup)); + this.setState(State.Idle(UpdateType.Setup));
+ } + }
+ else { + else {
@@ -126,7 +132,7 @@ index 6e076c7..81556b6 100644
+ return createUpdateURL(this.productService, quality, process.platform, process.arch); + return createUpdateURL(this.productService, quality, process.platform, process.arch);
} }
diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts
index 61109e5..2581f3b 100644 index 61109e5..06981b3 100644
--- a/src/vs/platform/update/electron-main/updateService.win32.ts --- a/src/vs/platform/update/electron-main/updateService.win32.ts
+++ b/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts
@@ -11,3 +11,2 @@ import { CancellationToken } from '../../../base/common/cancellation.js'; @@ -11,3 +11,2 @@ import { CancellationToken } from '../../../base/common/cancellation.js';
@@ -187,25 +193,28 @@ index 61109e5..2581f3b 100644
- return createUpdateURL(platform, quality, this.productService); - return createUpdateURL(platform, quality, this.productService);
+ return createUpdateURL(this.productService, quality, process.platform, process.arch, target); + return createUpdateURL(this.productService, quality, process.platform, process.arch, target);
} }
@@ -126,4 +141,7 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -126,4 +141,10 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
if (!update || !update.url || !update.version || !update.productVersion) { if (!update || !update.url || !update.version || !update.productVersion) {
- this.telemetryService.publicLog2<{ explicit: boolean }, UpdateNotAvailableClassification>('update:notAvailable', { explicit: !!context }); - this.telemetryService.publicLog2<{ explicit: boolean }, UpdateNotAvailableClassification>('update:notAvailable', { explicit: !!context });
+ this.setState(State.Idle(updateType)); + this.setState(State.Idle(updateType));
+ return Promise.resolve(null); + return Promise.resolve(null);
+ } + }
+
+ const fetchedVersion = update.productVersion.replace(/(\d+\.\d+\.\d+)(?:\.(\d+))(\-\w+)?/, '$1$3+$2');
+ const currentVersion = `${this.productService.version}+${this.productService.release}`;
+ if(semver.compareBuild(update.productVersion.replace(/(\d+\.\d+\.\d+)(?:\.(\d+))(?:\-\w+)?/, '$1+$2'), `${this.productService.version}+${this.productService.release}`) >= 0) { + if(semver.compareBuild(currentVersion, fetchedVersion) >= 0) {
this.setState(State.Idle(updateType)); this.setState(State.Idle(updateType));
@@ -158,3 +176,3 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -158,3 +179,3 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
- const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); - const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
+ const fastUpdatesEnabled = getUpdateType() == UpdateType.Setup && this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); + const fastUpdatesEnabled = getUpdateType() == UpdateType.Setup && this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
if (fastUpdatesEnabled) { if (fastUpdatesEnabled) {
@@ -170,3 +188,2 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -170,3 +191,2 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
.then(undefined, err => { .then(undefined, err => {
- this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('update:error', { messageHash: String(hash(String(err))) }); - this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('update:error', { messageHash: String(hash(String(err))) });
this.logService.error(err); this.logService.error(err);
@@ -254,6 +271,14 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -254,6 +274,14 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
} else { } else {
- spawn(this.availableUpdate.packagePath, ['/silent', '/log', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], { - spawn(this.availableUpdate.packagePath, ['/silent', '/log', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], {
- detached: true, - detached: true,