src/extensions/default/AutoUpdate/main.js
function checkUpdateStatus() {
        var filesToCache = ['.logs'],
            downloadCompleted = updateJsonHandler.get("downloadCompleted"),
            updateInitiatedInPrevSession = updateJsonHandler.get("updateInitiatedInPrevSession");

        if (downloadCompleted && updateInitiatedInPrevSession) {
            var isNewVersion = checkIfVersionUpdated();
            updateJsonHandler.reset();
            if (isNewVersion) {
                // We get here if the update was successful
                UpdateInfoBar.showUpdateBar({
                    type: "success",
                    title: Strings.UPDATE_SUCCESSFUL,
                    description: ""
                });
                HealthLogger.sendAnalyticsData(
                    autoUpdateEventNames.AUTOUPDATE_INSTALLATION_SUCCESS,
                    "autoUpdate",
                    "install",
                    "complete",
                    ""
                );
            } else {
                // We get here if the update started but failed
                checkInstallationStatus();
                UpdateInfoBar.showUpdateBar({
                    type: "error",
                    title: Strings.UPDATE_FAILED,
                    description: Strings.GO_TO_SITE
                });
            }
        } else if (downloadCompleted && !updateInitiatedInPrevSession) {
            // We get here if the download was complete and user selected UpdateLater
            if (brackets.platform === "mac") {
                filesToCache = ['.dmg', '.json'];
            } else if (brackets.platform === "win") {
                filesToCache = ['.msi', '.json'];
            }
        }

        postMessageToNode(MessageIds.PERFORM_CLEANUP, filesToCache);
    }
function checkUpdateStatus() {
        var filesToCache = ['.logs'],
            downloadCompleted = updateJsonHandler.get("downloadCompleted"),
            updateInitiatedInPrevSession = updateJsonHandler.get("updateInitiatedInPrevSession");

        if (downloadCompleted && updateInitiatedInPrevSession) {
            var isNewVersion = checkIfVersionUpdated();
            updateJsonHandler.reset();
            if (isNewVersion) {
                // We get here if the update was successful
                UpdateInfoBar.showUpdateBar({
                    type: "success",
                    title: Strings.UPDATE_SUCCESSFUL,
                    description: ""
                });
                HealthLogger.sendAnalyticsData(
                    autoUpdateEventNames.AUTOUPDATE_INSTALLATION_SUCCESS,
                    "autoUpdate",
                    "install",
                    "complete",
                    ""
                );
            } else {
                // We get here if the update started but failed
                checkInstallationStatus();
                UpdateInfoBar.showUpdateBar({
                    type: "error",
                    title: Strings.UPDATE_FAILED,
                    description: Strings.GO_TO_SITE
                });
            }
        } else if (downloadCompleted && !updateInitiatedInPrevSession) {
            // We get here if the download was complete and user selected UpdateLater
            if (brackets.platform === "mac") {
                filesToCache = ['.dmg', '.json'];
            } else if (brackets.platform === "win") {
                filesToCache = ['.msi', '.json'];
            }
        }

        postMessageToNode(MessageIds.PERFORM_CLEANUP, filesToCache);
    }
function checkUpdateStatus ( ) { var filesToCache = [ '.logs' ] , downloadCompleted = updateJsonHandler . get ( "downloadCompleted" ) , updateInitiatedInPrevSession = updateJsonHandler . get ( "updateInitiatedInPrevSession" ) ; if ( downloadCompleted && updateInitiatedInPrevSession ) { var isNewVersion = checkIfVersionUpdated ( ) ; updateJsonHandler . reset ( ) ; if ( isNewVersion ) { // We get here if the update was successful UpdateInfoBar . showUpdateBar ( { type : "success" , title : Strings . UPDATE_SUCCESSFUL , description : "" } ) ; HealthLogger . sendAnalyticsData ( autoUpdateEventNames . AUTOUPDATE_INSTALLATION_SUCCESS , "autoUpdate" , "install" , "complete" , "" ) ; } else { // We get here if the update started but failed checkInstallationStatus ( ) ; UpdateInfoBar . showUpdateBar ( { type : "error" , title : Strings . UPDATE_FAILED , description : Strings . GO_TO_SITE } ) ; } } else if ( downloadCompleted && ! updateInitiatedInPrevSession ) { // We get here if the download was complete and user selected UpdateLater if ( brackets . platform === "mac" ) { filesToCache = [ '.dmg' , '.json' ] ; } else if ( brackets . platform === "win" ) { filesToCache = [ '.msi' , '.json' ] ; } } postMessageToNode ( MessageIds . PERFORM_CLEANUP , filesToCache ) ; }
Checks and handles the update success and failure scenarios
Checks and handles the update success and failure scenarios