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

Auto Update Error Handlng Fix #14412

Merged
merged 2 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this getting called from?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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