未验证 提交 bfe8ff1d 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #53226 from Microsoft/joh/isLatest

IUpdateService#isLatestVersion
...@@ -89,4 +89,6 @@ export interface IUpdateService { ...@@ -89,4 +89,6 @@ export interface IUpdateService {
downloadUpdate(): TPromise<void>; downloadUpdate(): TPromise<void>;
applyUpdate(): TPromise<void>; applyUpdate(): TPromise<void>;
quitAndInstall(): TPromise<void>; quitAndInstall(): TPromise<void>;
}
\ No newline at end of file isLatestVersion(): TPromise<boolean | undefined>;
}
...@@ -17,6 +17,7 @@ export interface IUpdateChannel extends IChannel { ...@@ -17,6 +17,7 @@ export interface IUpdateChannel extends IChannel {
call(command: 'applyUpdate'): TPromise<void>; call(command: 'applyUpdate'): TPromise<void>;
call(command: 'quitAndInstall'): TPromise<void>; call(command: 'quitAndInstall'): TPromise<void>;
call(command: '_getInitialState'): TPromise<State>; call(command: '_getInitialState'): TPromise<State>;
call(command: 'isLatestVersion'): TPromise<boolean>;
call(command: string, arg?: any): TPromise<any>; call(command: string, arg?: any): TPromise<any>;
} }
...@@ -32,6 +33,7 @@ export class UpdateChannel implements IUpdateChannel { ...@@ -32,6 +33,7 @@ export class UpdateChannel implements IUpdateChannel {
case 'applyUpdate': return this.service.applyUpdate(); case 'applyUpdate': return this.service.applyUpdate();
case 'quitAndInstall': return this.service.quitAndInstall(); case 'quitAndInstall': return this.service.quitAndInstall();
case '_getInitialState': return TPromise.as(this.service.state); case '_getInitialState': return TPromise.as(this.service.state);
case 'isLatestVersion': return this.service.isLatestVersion();
} }
return undefined; return undefined;
} }
...@@ -77,4 +79,8 @@ export class UpdateChannelClient implements IUpdateService { ...@@ -77,4 +79,8 @@ export class UpdateChannelClient implements IUpdateService {
quitAndInstall(): TPromise<void> { quitAndInstall(): TPromise<void> {
return this.channel.call('quitAndInstall'); return this.channel.call('quitAndInstall');
} }
}
\ No newline at end of file isLatestVersion(): TPromise<boolean> {
return this.channel.call('isLatestVersion');
}
}
...@@ -14,6 +14,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; ...@@ -14,6 +14,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { IUpdateService, State, StateType, AvailableForDownload } from 'vs/platform/update/common/update'; import { IUpdateService, State, StateType, AvailableForDownload } from 'vs/platform/update/common/update';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { IRequestService } from 'vs/platform/request/node/request';
export function createUpdateURL(platform: string, quality: string): string { export function createUpdateURL(platform: string, quality: string): string {
return `${product.updateUrl}/api/update/${platform}/${quality}/${product.commit}`; return `${product.updateUrl}/api/update/${platform}/${quality}/${product.commit}`;
...@@ -23,6 +24,8 @@ export abstract class AbstractUpdateService implements IUpdateService { ...@@ -23,6 +24,8 @@ export abstract class AbstractUpdateService implements IUpdateService {
_serviceBrand: any; _serviceBrand: any;
protected readonly url: string | undefined;
private _state: State = State.Uninitialized; private _state: State = State.Uninitialized;
private throttler: Throttler = new Throttler(); private throttler: Throttler = new Throttler();
...@@ -43,7 +46,8 @@ export abstract class AbstractUpdateService implements IUpdateService { ...@@ -43,7 +46,8 @@ export abstract class AbstractUpdateService implements IUpdateService {
@ILifecycleService private lifecycleService: ILifecycleService, @ILifecycleService private lifecycleService: ILifecycleService,
@IConfigurationService protected configurationService: IConfigurationService, @IConfigurationService protected configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService, @IEnvironmentService private environmentService: IEnvironmentService,
@ILogService protected logService: ILogService @IRequestService protected requestService: IRequestService,
@ILogService protected logService: ILogService,
) { ) {
if (this.environmentService.disableUpdates) { if (this.environmentService.disableUpdates) {
this.logService.info('update#ctor - updates are disabled'); this.logService.info('update#ctor - updates are disabled');
...@@ -62,7 +66,8 @@ export abstract class AbstractUpdateService implements IUpdateService { ...@@ -62,7 +66,8 @@ export abstract class AbstractUpdateService implements IUpdateService {
return; return;
} }
if (!this.setUpdateFeedUrl(quality)) { this.url = this.buildUpdateFeedUrl(quality);
if (!this.url) {
this.logService.info('update#ctor - updates are disabled'); this.logService.info('update#ctor - updates are disabled');
return; return;
} }
...@@ -153,10 +158,25 @@ export abstract class AbstractUpdateService implements IUpdateService { ...@@ -153,10 +158,25 @@ export abstract class AbstractUpdateService implements IUpdateService {
return TPromise.as(null); return TPromise.as(null);
} }
isLatestVersion(): TPromise<boolean | undefined> {
if (!this.url) {
return TPromise.as(undefined);
}
return this.requestService.request({ url: this.url }).then(context => {
// The update server replies with 204 (No Content) when no
// update is available - that's all we want to know.
if (context.res.statusCode === 204) {
return true;
} else {
return false;
}
});
}
protected doQuitAndInstall(): void { protected doQuitAndInstall(): void {
// noop // noop
} }
protected abstract setUpdateFeedUrl(quality: string): boolean; protected abstract buildUpdateFeedUrl(quality: string): string | undefined;
protected abstract doCheckForUpdates(context: any): void; protected abstract doCheckForUpdates(context: any): void;
} }
...@@ -16,6 +16,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; ...@@ -16,6 +16,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { AbstractUpdateService, createUpdateURL } from 'vs/platform/update/electron-main/abstractUpdateService'; import { AbstractUpdateService, createUpdateURL } from 'vs/platform/update/electron-main/abstractUpdateService';
import { IRequestService } from 'vs/platform/request/node/request';
export class DarwinUpdateService extends AbstractUpdateService { export class DarwinUpdateService extends AbstractUpdateService {
...@@ -33,9 +34,10 @@ export class DarwinUpdateService extends AbstractUpdateService { ...@@ -33,9 +34,10 @@ export class DarwinUpdateService extends AbstractUpdateService {
@IConfigurationService configurationService: IConfigurationService, @IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private telemetryService: ITelemetryService, @ITelemetryService private telemetryService: ITelemetryService,
@IEnvironmentService environmentService: IEnvironmentService, @IEnvironmentService environmentService: IEnvironmentService,
@IRequestService requestService: IRequestService,
@ILogService logService: ILogService @ILogService logService: ILogService
) { ) {
super(lifecycleService, configurationService, environmentService, logService); super(lifecycleService, configurationService, environmentService, requestService, logService);
this.onRawError(this.onError, this, this.disposables); this.onRawError(this.onError, this, this.disposables);
this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables); this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables);
this.onRawUpdateDownloaded(this.onUpdateDownloaded, this, this.disposables); this.onRawUpdateDownloaded(this.onUpdateDownloaded, this, this.disposables);
...@@ -47,16 +49,16 @@ export class DarwinUpdateService extends AbstractUpdateService { ...@@ -47,16 +49,16 @@ export class DarwinUpdateService extends AbstractUpdateService {
this.setState(State.Idle); this.setState(State.Idle);
} }
protected setUpdateFeedUrl(quality: string): boolean { protected buildUpdateFeedUrl(quality: string): string | undefined {
const url = createUpdateURL('darwin', quality);
try { try {
electron.autoUpdater.setFeedURL(createUpdateURL('darwin', quality)); electron.autoUpdater.setFeedURL(url);
} catch (e) { } catch (e) {
// application is very likely not signed // application is very likely not signed
this.logService.error('Failed to set update feed URL', e); this.logService.error('Failed to set update feed URL', e);
return false; return undefined;
} }
return url;
return true;
} }
protected doCheckForUpdates(context: any): void { protected doCheckForUpdates(context: any): void {
......
...@@ -22,22 +22,19 @@ export class LinuxUpdateService extends AbstractUpdateService { ...@@ -22,22 +22,19 @@ export class LinuxUpdateService extends AbstractUpdateService {
_serviceBrand: any; _serviceBrand: any;
private url: string | undefined;
constructor( constructor(
@ILifecycleService lifecycleService: ILifecycleService, @ILifecycleService lifecycleService: ILifecycleService,
@IConfigurationService configurationService: IConfigurationService, @IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private telemetryService: ITelemetryService, @ITelemetryService private telemetryService: ITelemetryService,
@IEnvironmentService environmentService: IEnvironmentService, @IEnvironmentService environmentService: IEnvironmentService,
@IRequestService private requestService: IRequestService, @IRequestService requestService: IRequestService,
@ILogService logService: ILogService @ILogService logService: ILogService
) { ) {
super(lifecycleService, configurationService, environmentService, logService); super(lifecycleService, configurationService, environmentService, requestService, logService);
} }
protected setUpdateFeedUrl(quality: string): boolean { protected buildUpdateFeedUrl(quality: string): string {
this.url = createUpdateURL(`linux-${process.arch}`, quality); return createUpdateURL(`linux-${process.arch}`, quality);
return true;
} }
protected doCheckForUpdates(context: any): void { protected doCheckForUpdates(context: any): void {
......
...@@ -47,7 +47,6 @@ export class Win32UpdateService extends AbstractUpdateService { ...@@ -47,7 +47,6 @@ export class Win32UpdateService extends AbstractUpdateService {
_serviceBrand: any; _serviceBrand: any;
private url: string | undefined;
private availableUpdate: IAvailableUpdate | undefined; private availableUpdate: IAvailableUpdate | undefined;
@memoize @memoize
...@@ -61,15 +60,15 @@ export class Win32UpdateService extends AbstractUpdateService { ...@@ -61,15 +60,15 @@ export class Win32UpdateService extends AbstractUpdateService {
@IConfigurationService configurationService: IConfigurationService, @IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private telemetryService: ITelemetryService, @ITelemetryService private telemetryService: ITelemetryService,
@IEnvironmentService environmentService: IEnvironmentService, @IEnvironmentService environmentService: IEnvironmentService,
@IRequestService private requestService: IRequestService, @IRequestService requestService: IRequestService,
@ILogService logService: ILogService @ILogService logService: ILogService
) { ) {
super(lifecycleService, configurationService, environmentService, logService); super(lifecycleService, configurationService, environmentService, requestService, logService);
} }
protected setUpdateFeedUrl(quality: string): boolean { protected buildUpdateFeedUrl(quality: string): string | undefined {
if (!fs.existsSync(path.join(path.dirname(process.execPath), 'unins000.exe'))) { if (!fs.existsSync(path.join(path.dirname(process.execPath), 'unins000.exe'))) {
return false; return undefined;
} }
let platform = 'win32'; let platform = 'win32';
...@@ -82,8 +81,7 @@ export class Win32UpdateService extends AbstractUpdateService { ...@@ -82,8 +81,7 @@ export class Win32UpdateService extends AbstractUpdateService {
platform += '-user'; platform += '-user';
} }
this.url = createUpdateURL(platform, quality); return createUpdateURL(platform, quality);
return true;
} }
protected doCheckForUpdates(context: any): void { protected doCheckForUpdates(context: any): void {
......
...@@ -21,6 +21,7 @@ import { isCodeEditor } from 'vs/editor/browser/editorBrowser'; ...@@ -21,6 +21,7 @@ import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IUpdateService } from 'vs/platform/update/common/update';
class StartupTimings implements IWorkbenchContribution { class StartupTimings implements IWorkbenchContribution {
...@@ -34,6 +35,7 @@ class StartupTimings implements IWorkbenchContribution { ...@@ -34,6 +35,7 @@ class StartupTimings implements IWorkbenchContribution {
@ITelemetryService private readonly _telemetryService: ITelemetryService, @ITelemetryService private readonly _telemetryService: ITelemetryService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService, @ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IExtensionService private readonly _extensionService: IExtensionService, @IExtensionService private readonly _extensionService: IExtensionService,
@IUpdateService private readonly _updateService: IUpdateService,
) { ) {
this._reportVariedStartupTimes().then(undefined, onUnexpectedError); this._reportVariedStartupTimes().then(undefined, onUnexpectedError);
...@@ -87,7 +89,10 @@ class StartupTimings implements IWorkbenchContribution { ...@@ -87,7 +89,10 @@ class StartupTimings implements IWorkbenchContribution {
this._logService.info('no standard startup: not using cached data'); this._logService.info('no standard startup: not using cached data');
return; return;
} }
if (!await this._updateService.isLatestVersion()) {
this._logService.info('no standard startup: not running latest version');
return;
}
// wait only know so that can check the restored state as soon as possible // wait only know so that can check the restored state as soon as possible
await TPromise.join([ await TPromise.join([
this._extensionService.whenInstalledExtensionsRegistered(), this._extensionService.whenInstalledExtensionsRegistered(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册