diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index d5987fcd97..bdf6ff13e3 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -967,10 +967,10 @@ Zotero.Schema = new function(){ /** * Send XMLHTTP request for updated translators and styles to the central repository * - * @param {Boolean} force Force a repository query regardless of how - * long it's been since the last check + * @param {Integer} [force=0] - If non-zero, force a repository query regardless of how long it's + * been since the last check. 1 means manual update, 2 means forced update after upgrade. */ - this.updateFromRepository = Zotero.Promise.coroutine(function* (force) { + this.updateFromRepository = Zotero.Promise.coroutine(function* (force = 0) { if (!force) { if (_remoteUpdateInProgress) { Zotero.debug("A remote update is already in progress -- not checking repository"); @@ -1025,13 +1025,11 @@ Zotero.Schema = new function(){ _remoteUpdateInProgress = true; - if (force) { - if (force == 2) { - url += '&m=2'; - } - else { - url += '&m=1'; - } + if (force == 2) { + url += '&m=2'; + } + else if (force) { + url += '&m=1'; } // Send list of installed styles @@ -1054,7 +1052,7 @@ Zotero.Schema = new function(){ try { var xmlhttp = yield Zotero.HTTP.request("POST", url, { body: body }); - return _updateFromRepositoryCallback(xmlhttp, !!force); + return _updateFromRepositoryCallback(xmlhttp, force); } catch (e) { if (e instanceof Zotero.HTTP.UnexpectedStatusException @@ -1493,7 +1491,7 @@ Zotero.Schema = new function(){ * * @return {Promise:Boolean} A promise for whether the update suceeded **/ - function _updateFromRepositoryCallback(xmlhttp, manual) { + function _updateFromRepositoryCallback(xmlhttp, force) { if (!xmlhttp.responseXML){ try { if (xmlhttp.status>1000){ @@ -1509,7 +1507,7 @@ Zotero.Schema = new function(){ Zotero.debug('Repository cannot be contacted'); } - if (!manual){ + if (!force) { _setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']); } @@ -1642,7 +1640,7 @@ Zotero.Schema = new function(){ }) .then(function () { Zotero.debug('All translators and styles are up-to-date'); - if (!manual) { + if (!force) { _setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']); } @@ -1664,12 +1662,12 @@ Zotero.Schema = new function(){ } // Rebuild caches - yield Zotero.Translators.reinit({ fromSchemaUpdate: true }); - yield Zotero.Styles.reinit({ fromSchemaUpdate: true }); + yield Zotero.Translators.reinit({ fromSchemaUpdate: force != 1 }); + yield Zotero.Styles.reinit({ fromSchemaUpdate: force != 1 }); } catch (e) { Zotero.debug(e, 1); - if (!manual){ + if (!force) { _setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']); } return false; @@ -1688,7 +1686,7 @@ Zotero.Schema = new function(){ yield _updateDBVersion('lastcheck', lastCheckTime); }) .then(function () { - if (!manual) { + if (!force) { _setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']); }