@@ -223,6 +223,7 @@ define(function (require, exports, module) {
223
223
224
224
if ( downloadCompleted && updateInitiatedInPrevSession ) {
225
225
var isNewVersion = checkIfVersionUpdated ( ) ;
226
+ updateJsonHandler . reset ( ) ;
226
227
if ( isNewVersion ) {
227
228
// We get here if the update was successful
228
229
UpdateInfoBar . showUpdateBar ( {
@@ -280,19 +281,14 @@ define(function (require, exports, module) {
280
281
281
282
/**
282
283
* Initializes the state of parsed content from updateHelper.json
284
+ * returns Promise Object Which is resolved when parsing is success
285
+ * and rejected if parsing is failed.
283
286
*/
284
287
function initState ( ) {
288
+ var result = $ . Deferred ( ) ;
285
289
updateJsonHandler . parse ( )
286
290
. done ( function ( ) {
287
- checkIfAnotherSessionInProgress ( )
288
- . done ( function ( inProgress ) {
289
- if ( ! inProgress ) {
290
- checkUpdateStatus ( ) ;
291
- }
292
- } )
293
- . fail ( function ( ) {
294
- checkUpdateStatus ( ) ;
295
- } ) ;
291
+ result . resolve ( ) ;
296
292
} )
297
293
. fail ( function ( code ) {
298
294
var logMsg ;
@@ -311,7 +307,9 @@ define(function (require, exports, module) {
311
307
break ;
312
308
}
313
309
console . log ( logMsg ) ;
310
+ result . reject ( ) ;
314
311
} ) ;
312
+ return result . promise ( ) ;
315
313
}
316
314
317
315
@@ -321,15 +319,13 @@ define(function (require, exports, module) {
321
319
*/
322
320
function setupAutoUpdate ( ) {
323
321
updateJsonHandler = new StateHandler ( updateJsonPath ) ;
322
+ updateDomain . on ( 'data' , receiveMessageFromNode ) ;
324
323
325
324
updateDomain . exec ( 'initNode' , {
326
325
messageIds : MessageIds ,
327
326
updateDir : updateDir ,
328
327
requester : domainID
329
328
} ) ;
330
-
331
- updateDomain . on ( 'data' , receiveMessageFromNode ) ;
332
- initState ( ) ;
333
329
}
334
330
335
331
@@ -594,11 +590,17 @@ define(function (require, exports, module) {
594
590
/**
595
591
* Enables/disables the state of "Auto Update In Progress" in UpdateHandler.json
596
592
*/
597
- function setAutoUpdateInProgressFlag ( flag ) {
598
- updateJsonHandler . parse ( )
599
- . done ( function ( ) {
600
- setUpdateStateInJSON ( "autoUpdateInProgress" , flag ) ;
601
- } ) ;
593
+ function nodeDomainInitialized ( reset ) {
594
+ initState ( )
595
+ . done ( function ( ) {
596
+ var inProgress = updateJsonHandler . get ( updateProgressKey ) ;
597
+ if ( inProgress && reset ) {
598
+ setUpdateStateInJSON ( updateProgressKey , ! reset )
599
+ . always ( checkUpdateStatus ) ;
600
+ } else if ( ! inProgress ) {
601
+ checkUpdateStatus ( ) ;
602
+ }
603
+ } ) ;
602
604
}
603
605
604
606
@@ -636,7 +638,6 @@ define(function (require, exports, module) {
636
638
enableCheckForUpdateEntry ( true ) ;
637
639
console . error ( message ) ;
638
640
639
- setUpdateStateInJSON ( "autoUpdateInProgress" , false ) ;
640
641
}
641
642
642
643
/**
@@ -1124,7 +1125,7 @@ define(function (require, exports, module) {
1124
1125
1125
1126
ProjectManager . on ( "beforeProjectClose beforeAppClose" , _handleAppClose ) ;
1126
1127
}
1127
- functionMap [ "brackets.setAutoUpdateInProgress " ] = setAutoUpdateInProgressFlag ;
1128
+ functionMap [ "brackets.nodeDomainInitialized " ] = nodeDomainInitialized ;
1128
1129
functionMap [ "brackets.registerBracketsFunctions" ] = registerBracketsFunctions ;
1129
1130
1130
1131
} ) ;
0 commit comments