diff --git a/src/vs/platform/update/electron-main/updateService.linux.ts b/src/vs/platform/update/electron-main/updateService.linux.ts index 12d660bb203..71fe0626655 100644 --- a/src/vs/platform/update/electron-main/updateService.linux.ts +++ b/src/vs/platform/update/electron-main/updateService.linux.ts @@ -84,8 +84,8 @@ export class LinuxUpdateService extends AbstractUpdateService { } else { shell.openExternal(state.update.url); } - this.setState(State.Idle); + this.setState(State.Idle); return TPromise.as(null); } } diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts index 6ac195ed9de..003a2a5492a 100644 --- a/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts @@ -14,7 +14,7 @@ import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycle import { IRequestService } from 'vs/platform/request/node/request'; import product from 'vs/platform/node/product'; import { TPromise, Promise } from 'vs/base/common/winjs.base'; -import { State, IUpdate, StateType } from 'vs/platform/update/common/update'; +import { State, IUpdate, StateType, AvailableForDownload } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; @@ -23,6 +23,7 @@ import { download, asJson } from 'vs/base/node/request'; import { checksum } from 'vs/base/node/crypto'; import { tmpdir } from 'os'; import { spawn } from 'child_process'; +import { shell } from 'electron'; function pollUntil(fn: () => boolean, timeout = 1000): TPromise { return new TPromise(c => { @@ -43,12 +44,18 @@ interface IAvailableUpdate { updateFilePath?: string; } +enum UpdateType { + Automatic, + Manual +} + export class Win32UpdateService extends AbstractUpdateService { _serviceBrand: any; private url: string | undefined; private availableUpdate: IAvailableUpdate | undefined; + private updateType: UpdateType; @memoize get cachePath(): TPromise { @@ -65,13 +72,13 @@ export class Win32UpdateService extends AbstractUpdateService { @ILogService logService: ILogService ) { super(lifecycleService, configurationService, environmentService, logService); + + this.updateType = fs.existsSync(path.join(path.dirname(process.execPath), 'unins000.exe')) + ? UpdateType.Automatic + : UpdateType.Manual; } protected setUpdateFeedUrl(quality: string): boolean { - if (!fs.existsSync(path.join(path.dirname(process.execPath), 'unins000.exe'))) { - return false; - } - let platform = 'win32'; if (process.arch === 'x64') { @@ -96,7 +103,7 @@ export class Win32UpdateService extends AbstractUpdateService { this.requestService.request({ url: this.url }) .then(asJson) .then(update => { - if (!update || !update.url || !update.version) { + if (!update || !update.url || !update.version || !update.productVersion) { /* __GDPR__ "update:notAvailable" : { "explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true } @@ -108,6 +115,11 @@ export class Win32UpdateService extends AbstractUpdateService { return TPromise.as(null); } + if (this.updateType === UpdateType.Manual) { + this.setState(State.AvailableForDownload(update)); + return TPromise.as(null); + } + this.setState(State.Downloading(update)); return this.cleanup(update.version).then(() => { @@ -156,6 +168,19 @@ export class Win32UpdateService extends AbstractUpdateService { }); } + protected doDownloadUpdate(state: AvailableForDownload): TPromise { + // Use the download URL if available as we don't currently detect the package type that was + // installed and the website download page is more useful than the tarball generally. + if (product.downloadUrl && product.downloadUrl.length > 0) { + shell.openExternal(product.downloadUrl); + } else { + shell.openExternal(state.update.url); + } + + this.setState(State.Idle); + return TPromise.as(null); + } + private getUpdatePackagePath(version: string): TPromise { return this.cachePath.then(cachePath => path.join(cachePath, `CodeSetup-${product.quality}-${version}.exe`)); }