Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Auto Update Error Handlng Fix (#14412)
Browse files Browse the repository at this point in the history
* Auto Update Error Handlng Fix

* Addressed Review comments
  • Loading branch information
niteskum authored and nethip committed Dec 3, 2018
1 parent 53a5254 commit cca4422
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/extensions/default/AutoUpdate/MessageIds.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ define(function (require, exports, module) {
exports.NOTIFY_INITIALIZATION_COMPLETE = "brackets.notifyinitializationComplete";
exports.NOTIFY_VALIDATION_STATUS = "brackets.notifyvalidationStatus";
exports.NOTIFY_INSTALLATION_STATUS = "brackets.notifyInstallationStatus";
exports.SET_UPDATE_IN_PROGRESS_STATE = "brackets.setAutoUpdateInProgress";
exports.NODE_DOMAIN_INITIALIZED = "brackets.nodeDomainInitialized";
exports.REGISTER_BRACKETS_FUNCTIONS = "brackets.registerBracketsFunctions";
});
39 changes: 20 additions & 19 deletions src/extensions/default/AutoUpdate/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ define(function (require, exports, module) {

if (downloadCompleted && updateInitiatedInPrevSession) {
var isNewVersion = checkIfVersionUpdated();
updateJsonHandler.reset();
if (isNewVersion) {
// We get here if the update was successful
UpdateInfoBar.showUpdateBar({
Expand Down Expand Up @@ -280,19 +281,14 @@ define(function (require, exports, module) {

/**
* Initializes the state of parsed content from updateHelper.json
* returns Promise Object Which is resolved when parsing is success
* and rejected if parsing is failed.
*/
function initState() {
var result = $.Deferred();
updateJsonHandler.parse()
.done(function() {
checkIfAnotherSessionInProgress()
.done(function (inProgress) {
if (!inProgress) {
checkUpdateStatus();
}
})
.fail(function () {
checkUpdateStatus();
});
result.resolve();
})
.fail(function (code) {
var logMsg;
Expand All @@ -311,7 +307,9 @@ define(function (require, exports, module) {
break;
}
console.log(logMsg);
result.reject();
});
return result.promise();
}


Expand All @@ -321,15 +319,13 @@ define(function (require, exports, module) {
*/
function setupAutoUpdate() {
updateJsonHandler = new StateHandler(updateJsonPath);
updateDomain.on('data', receiveMessageFromNode);

updateDomain.exec('initNode', {
messageIds: MessageIds,
updateDir: updateDir,
requester: domainID
});

updateDomain.on('data', receiveMessageFromNode);
initState();
}


Expand Down Expand Up @@ -594,11 +590,17 @@ define(function (require, exports, module) {
/**
* Enables/disables the state of "Auto Update In Progress" in UpdateHandler.json
*/
function setAutoUpdateInProgressFlag(flag) {
updateJsonHandler.parse()
.done(function() {
setUpdateStateInJSON("autoUpdateInProgress", flag);
});
function nodeDomainInitialized(reset) {
initState()
.done(function () {
var inProgress = updateJsonHandler.get(updateProgressKey);
if (inProgress && reset) {
setUpdateStateInJSON(updateProgressKey, !reset)
.always(checkUpdateStatus);
} else if (!inProgress) {
checkUpdateStatus();
}
});
}


Expand Down Expand Up @@ -636,7 +638,6 @@ define(function (require, exports, module) {
enableCheckForUpdateEntry(true);
console.error(message);

setUpdateStateInJSON("autoUpdateInProgress", false);
}

/**
Expand Down Expand Up @@ -1124,7 +1125,7 @@ define(function (require, exports, module) {

ProjectManager.on("beforeProjectClose beforeAppClose", _handleAppClose);
}
functionMap["brackets.setAutoUpdateInProgress"] = setAutoUpdateInProgressFlag;
functionMap["brackets.nodeDomainInitialized"] = nodeDomainInitialized;
functionMap["brackets.registerBracketsFunctions"] = registerBracketsFunctions;

});
4 changes: 3 additions & 1 deletion src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,17 @@
* requester : ID of the current requester domain}
*/
function initNode(initObj) {
var resetUpdateProgres = false;
if (!isNodeDomainInitialized) {
MessageIds = initObj.messageIds;
updateDir = path.resolve(initObj.updateDir);
logFilePath = path.resolve(updateDir, logFile);
installStatusFilePath = path.resolve(updateDir, installStatusFile);
registerNodeFunctions();
isNodeDomainInitialized = true;
postMessageToBrackets(MessageIds.SET_UPDATE_IN_PROGRESS_STATE, initObj.requester.toString(), false);
resetUpdateProgres = true;
}
postMessageToBrackets(MessageIds.NODE_DOMAIN_INITIALIZED, initObj.requester.toString(), resetUpdateProgres);
requesters[initObj.requester.toString()] = true;
postMessageToBrackets(MessageIds.REGISTER_BRACKETS_FUNCTIONS, initObj.requester.toString());
}
Expand Down

0 comments on commit cca4422

Please sign in to comment.