@@ -45,6 +45,12 @@ export class UpdateService implements IUpdateService {
4545 private _onUpdateNotAvailable = new Emitter < boolean > ( ) ;
4646 get onUpdateNotAvailable ( ) : Event < boolean > { return this . _onUpdateNotAvailable . event ; }
4747
48+ private _onUpdateDownloaded = new Emitter < IRawUpdate > ( ) ;
49+ get onUpdateDownloaded ( ) : Event < IRawUpdate > { return this . _onUpdateDownloaded . event ; }
50+
51+ private _onUpdateInstalling = new Emitter < IRawUpdate > ( ) ;
52+ get onUpdateInstalling ( ) : Event < IRawUpdate > { return this . _onUpdateInstalling . event ; }
53+
4854 private _onUpdateReady = new Emitter < IRawUpdate > ( ) ;
4955 get onUpdateReady ( ) : Event < IRawUpdate > { return this . _onUpdateReady . event ; }
5056
@@ -68,14 +74,19 @@ export class UpdateService implements IUpdateService {
6874
6975 @memoize
7076 private get onRawUpdateDownloaded ( ) : Event < IRawUpdate > {
71- return fromNodeEventEmitter ( this . raw , 'update-downloaded' , ( _ , releaseNotes , version , date , url ) => ( { releaseNotes, version, date } ) ) ;
77+ return fromNodeEventEmitter ( this . raw , 'update-downloaded' , ( _ , releaseNotes , version , date , url , supportsFastUpdate ) => ( { releaseNotes, version, date, supportsFastUpdate } ) ) ;
78+ }
79+
80+ @memoize
81+ private get onRawUpdateReady ( ) : Event < IRawUpdate > {
82+ return fromNodeEventEmitter ( this . raw , 'update-ready' ) ;
7283 }
7384
7485 get state ( ) : State {
7586 return this . _state ;
7687 }
7788
78- set state ( state : State ) {
89+ private updateState ( state : State ) : void {
7990 this . _state = state ;
8091 this . _onStateChange . fire ( state ) ;
8192 }
@@ -119,7 +130,7 @@ export class UpdateService implements IUpdateService {
119130 return ; // application not signed
120131 }
121132
122- this . state = State . Idle ;
133+ this . updateState ( State . Idle ) ;
123134
124135 // Start checking for updates after 30 seconds
125136 this . scheduleCheckForUpdates ( 30 * 1000 )
@@ -157,27 +168,28 @@ export class UpdateService implements IUpdateService {
157168 }
158169
159170 this . _onCheckForUpdate . fire ( ) ;
160- this . state = State . CheckingForUpdate ;
171+ this . updateState ( State . CheckingForUpdate ) ;
161172
162173 const listeners : IDisposable [ ] = [ ] ;
163174 const result = new TPromise < IUpdate > ( ( c , e ) => {
164175 once ( this . onRawError ) ( e , null , listeners ) ;
165176 once ( this . onRawUpdateNotAvailable ) ( ( ) => c ( null ) , null , listeners ) ;
166177 once ( this . onRawUpdateAvailable ) ( ( { url, version } ) => url && c ( { url, version } ) , null , listeners ) ;
167- once ( this . onRawUpdateDownloaded ) ( ( { version, date, releaseNotes } ) => c ( { version, date, releaseNotes } ) , null , listeners ) ;
178+ once ( this . onRawUpdateDownloaded ) ( ( { version, date, releaseNotes, supportsFastUpdate } ) => c ( { version, date, releaseNotes, supportsFastUpdate } ) , null , listeners ) ;
168179
169180 this . raw . checkForUpdates ( ) ;
170181 } ) . then ( update => {
171182 if ( ! update ) {
172183 this . _onUpdateNotAvailable . fire ( explicit ) ;
173- this . state = State . Idle ;
184+ this . updateState ( State . Idle ) ;
174185 /* __GDPR__
175186 "update:notAvailable" : {
176187 "explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
177188 }
178189 */
179190 this . telemetryService . publicLog ( 'update:notAvailable' , { explicit } ) ;
180191
192+ // LINUX
181193 } else if ( update . url ) {
182194 const data : IUpdate = {
183195 url : update . url ,
@@ -188,7 +200,7 @@ export class UpdateService implements IUpdateService {
188200
189201 this . _availableUpdate = data ;
190202 this . _onUpdateAvailable . fire ( { url : update . url , version : update . version } ) ;
191- this . state = State . UpdateAvailable ;
203+ this . updateState ( State . UpdateAvailable ) ;
192204 /* __GDPR__
193205 "update:available" : {
194206 "explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
@@ -202,12 +214,20 @@ export class UpdateService implements IUpdateService {
202214 const data : IRawUpdate = {
203215 releaseNotes : update . releaseNotes ,
204216 version : update . version ,
205- date : update . date
217+ date : update . date ,
218+ supportsFastUpdate : update . supportsFastUpdate
206219 } ;
207220
208221 this . _availableUpdate = data ;
209- this . _onUpdateReady . fire ( data ) ;
210- this . state = State . UpdateDownloaded ;
222+
223+ if ( update . supportsFastUpdate ) {
224+ this . _onUpdateDownloaded . fire ( data ) ;
225+ this . updateState ( State . UpdateDownloaded ) ;
226+ } else {
227+ this . _onUpdateReady . fire ( data ) ;
228+ this . updateState ( State . UpdateReady ) ;
229+ }
230+
211231 /* __GDPR__
212232 "update:downloaded" : {
213233 "version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
@@ -218,7 +238,7 @@ export class UpdateService implements IUpdateService {
218238
219239 return update ;
220240 } , err => {
221- this . state = State . Idle ;
241+ this . updateState ( State . Idle ) ;
222242 return TPromise . wrapError < IUpdate > ( err ) ;
223243 } ) ;
224244
@@ -260,6 +280,26 @@ export class UpdateService implements IUpdateService {
260280 return process . platform ;
261281 }
262282
283+ // for windows fast updates
284+ applyUpdate ( ) : TPromise < void > {
285+ if ( this . state !== State . UpdateDownloaded ) {
286+ return TPromise . as ( null ) ;
287+ }
288+
289+ if ( ! this . raw . applyUpdate ) {
290+ return TPromise . as ( null ) ;
291+ }
292+
293+ once ( this . onRawUpdateReady ) ( ( ) => {
294+ this . _onUpdateReady . fire ( this . _availableUpdate as IRawUpdate ) ;
295+ this . updateState ( State . UpdateReady ) ;
296+ } ) ;
297+
298+ this . _onUpdateInstalling . fire ( this . _availableUpdate as IRawUpdate ) ;
299+ this . updateState ( State . UpdateInstalling ) ;
300+ return this . raw . applyUpdate ( ) ;
301+ }
302+
263303 quitAndInstall ( ) : TPromise < void > {
264304 if ( ! this . _availableUpdate ) {
265305 return TPromise . as ( null ) ;
0 commit comments