From 69778c0103f5a2089146d62404323f161bfcb772 Mon Sep 17 00:00:00 2001 From: Himanshu Date: Tue, 25 Feb 2025 14:52:19 +0530 Subject: [PATCH] winupdate: autocheck - manual download --- .../electron-main/updateService.win32.ts | 89 ++++++++++--------- .../parts/titlebar/media/titlebarpart.css | 2 +- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts index e28f7f1c857ef..14e7b251cbf62 100644 --- a/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts @@ -130,47 +130,11 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun return Promise.resolve(null); } - if (updateType === UpdateType.Archive) { - this.setState(State.AvailableForDownload(update)); - return Promise.resolve(null); - } - - this.setState(State.Downloading); - - return this.cleanup(update.version).then(() => { - return this.getUpdatePackagePath(update.version).then(updatePackagePath => { - return pfs.Promises.exists(updatePackagePath).then(exists => { - if (exists) { - return Promise.resolve(updatePackagePath); - } - - const downloadPath = `${updatePackagePath}.tmp`; - - return this.requestService.request({ url: update.url }, CancellationToken.None) - .then(context => this.fileService.writeFile(URI.file(downloadPath), context.stream)) - .then(update.sha256hash ? () => checksum(downloadPath, update.sha256hash) : () => undefined) - .then(() => pfs.Promises.rename(downloadPath, updatePackagePath, false /* no retry */)) - .then(() => updatePackagePath); - }); - }).then(packagePath => { - this.availableUpdate = { packagePath }; - this.setState(State.Downloaded(update)); - // NOTE: pear does not support fast updates. so we are setting the state to ready. - this.setState(State.Ready(update)); - - // const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); - // if (fastUpdatesEnabled) { - // if (this.productService.target === 'user') { - // this.doApplyUpdate(); - // } - // } else { - // this.setState(State.Ready(update)); - // } - }); - }); + this.setState(State.AvailableForDownload(update)); + return Promise.resolve(null); }) .then(undefined, err => { - this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('update:error', { messageHash: String(hash(String(err))) }); + this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('updateCheck:error', { messageHash: String(hash(String(err))) }); this.logService.error(err); // only show message when explicitly checking for updates @@ -180,10 +144,51 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun } protected override async doDownloadUpdate(state: AvailableForDownload): Promise { - if (state.update.url) { - this.nativeHostMainService.openExternal(undefined, state.update.url); + if (getUpdateType() === UpdateType.Archive) { + if (state.update.url) { + this.nativeHostMainService.openExternal(undefined, state.update.url); + } + this.setState(State.Idle(getUpdateType())); } - this.setState(State.Idle(getUpdateType())); + + if (this.state.type !== StateType.AvailableForDownload) + return; + + const update = this.state.update; + + this.setState(State.Downloading); + + return this.cleanup(update.version).then(() => { + return this.getUpdatePackagePath(update.version).then(updatePackagePath => { + return pfs.Promises.exists(updatePackagePath).then(exists => { + if (exists) { + return Promise.resolve(updatePackagePath); + } + + const downloadPath = `${updatePackagePath}.tmp`; + + return this.requestService.request({ url: update.url }, CancellationToken.None) + .then(context => this.fileService.writeFile(URI.file(downloadPath), context.stream)) + .then(update.sha256hash ? () => checksum(downloadPath, update.sha256hash) : () => undefined) + .then(() => pfs.Promises.rename(downloadPath, updatePackagePath, false /* no retry */)) + .then(() => updatePackagePath); + }); + }).then(packagePath => { + this.availableUpdate = { packagePath }; + this.setState(State.Downloaded(update)); + // NOTE: pear does not support fast updates. so we are setting the state to ready. + this.setState(State.Ready(update)); + + // const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); + // if (fastUpdatesEnabled) { + // if (this.productService.target === 'user') { + // this.doApplyUpdate(); + // } + // } else { + // this.setState(State.Ready(update)); + // } + }); + }); } private async getUpdatePackagePath(version: string): Promise { diff --git a/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css b/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css index 267d713458fc8..6348634dea30d 100644 --- a/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css +++ b/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css @@ -481,7 +481,7 @@ align-items: center; justify-content: center; cursor: pointer; - border-radius: 16px; + border-radius: 8px; padding: 6px 8px; margin: 5px 6px; color: var(--vscode-button-foreground);