@@ -14,6 +14,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
1414import { IUpdateService , State , StateType , AvailableForDownload } from 'vs/platform/update/common/update' ;
1515import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
1616import { ILogService } from 'vs/platform/log/common/log' ;
17+ import { IRequestService } from 'vs/platform/request/node/request' ;
1718
1819export function createUpdateURL ( platform : string , quality : string ) : string {
1920 return `${ product . updateUrl } /api/update/${ platform } /${ quality } /${ product . commit } ` ;
@@ -23,6 +24,8 @@ export abstract class AbstractUpdateService implements IUpdateService {
2324
2425 _serviceBrand : any ;
2526
27+ protected readonly url : string | undefined ;
28+
2629 private _state : State = State . Uninitialized ;
2730 private throttler : Throttler = new Throttler ( ) ;
2831
@@ -43,7 +46,8 @@ export abstract class AbstractUpdateService implements IUpdateService {
4346 @ILifecycleService private lifecycleService : ILifecycleService ,
4447 @IConfigurationService protected configurationService : IConfigurationService ,
4548 @IEnvironmentService private environmentService : IEnvironmentService ,
46- @ILogService protected logService : ILogService
49+ @IRequestService protected requestService : IRequestService ,
50+ @ILogService protected logService : ILogService ,
4751 ) {
4852 if ( this . environmentService . disableUpdates ) {
4953 this . logService . info ( 'update#ctor - updates are disabled' ) ;
@@ -62,7 +66,8 @@ export abstract class AbstractUpdateService implements IUpdateService {
6266 return ;
6367 }
6468
65- if ( ! this . setUpdateFeedUrl ( quality ) ) {
69+ this . url = this . buildUpdateFeedUrl ( quality ) ;
70+ if ( ! this . url ) {
6671 this . logService . info ( 'update#ctor - updates are disabled' ) ;
6772 return ;
6873 }
@@ -153,10 +158,25 @@ export abstract class AbstractUpdateService implements IUpdateService {
153158 return TPromise . as ( null ) ;
154159 }
155160
161+ isLatestVersion ( ) : TPromise < boolean | undefined > {
162+ if ( ! this . url ) {
163+ return TPromise . as ( undefined ) ;
164+ }
165+ return this . requestService . request ( { url : this . url } ) . then ( context => {
166+ // The update server replies with 204 (No Content) when no
167+ // update is available - that's all we want to know.
168+ if ( context . res . statusCode === 204 ) {
169+ return true ;
170+ } else {
171+ return false ;
172+ }
173+ } ) ;
174+ }
175+
156176 protected doQuitAndInstall ( ) : void {
157177 // noop
158178 }
159179
160- protected abstract setUpdateFeedUrl ( quality : string ) : boolean ;
180+ protected abstract buildUpdateFeedUrl ( quality : string ) : string ;
161181 protected abstract doCheckForUpdates ( context : any ) : void ;
162182}
0 commit comments