From c870710fcbf4729fc9939544994a8b9bcda06937 Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Tue, 7 Feb 2017 19:51:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=20send=20LTS=20parameter=20if?= =?UTF-8?q?=20requesting=20the=20update=20check=20service=20(#7954)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - the update check service now supports a LTS option - sending lts=false will force the update check service to search for the latest non LTS release - as 1.0.0 is still in alpha, there is no latest release available - that's why the update check service returns an error saying, there is no latest release available - this error get's logged to shell right now - as soon as we release 1.0.0, the error auto disappears No behaviour change in any previous alpha version or any LTS release as they don't send the LTS option. --- core/server/update-check.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/core/server/update-check.js b/core/server/update-check.js index 07ea0a3386..bbd0f383fe 100644 --- a/core/server/update-check.js +++ b/core/server/update-check.js @@ -39,16 +39,16 @@ var crypto = require('crypto'), checkEndpoint = 'updates.ghost.org'; function updateCheckError(err) { + err = errors.utils.deserialize(err); + api.settings.edit( {settings: [{key: 'nextUpdateCheck', value: Math.round(Date.now() / 1000 + 24 * 3600)}]}, internal ); - logging.error(new errors.GhostError({ - err: err, - context: i18n.t('errors.update-check.checkingForUpdatesFailed.error'), - help: i18n.t('errors.update-check.checkingForUpdatesFailed.help', {url: 'http://support.ghost.org'}) - })); + err.context = i18n.t('errors.update-check.checkingForUpdatesFailed.error'); + err.help = i18n.t('errors.update-check.checkingForUpdatesFailed.help', {url: 'http://support.ghost.org'}); + logging.error(err); } /** @@ -126,6 +126,7 @@ function updateCheckData() { data.user_count = users && users.users && users.users.length ? users.users.length : 0; data.blog_created_at = users && users.users && users.users[0] && users.users[0].created_at ? moment(users.users[0].created_at).unix() : ''; data.npm_version = npm.trim(); + data.lts = false; return data; }).catch(updateCheckError); @@ -155,6 +156,11 @@ function updateCheckRequest() { res.on('end', function onEnd() { try { resData = JSON.parse(resData); + + if (this.statusCode >= 400) { + return reject(resData); + } + resolve(resData); } catch (e) { reject(i18n.t('errors.update-check.unableToDecodeUpdateResponse.error')); @@ -202,6 +208,11 @@ function updateCheckResponse(response) { api.settings.edit({settings: [{key: 'displayUpdateNotification', value: response.version}]}, internal) ]).then(function () { var messages = response.messages || []; + + /** + * by default the update check service returns messages: [] + * but the latest release version get's stored anyway, because we adding the `displayUpdateNotification` ^ + */ return Promise.map(messages, createCustomNotification); }); } @@ -230,13 +241,6 @@ function showUpdateNotification() { return api.settings.read(_.extend({key: 'displayUpdateNotification'}, internal)).then(function then(response) { var display = response.settings[0]; - // Version 0.4 used boolean to indicate the need for an update. This special case is - // translated to the version string. - // TODO: remove in future version. - if (display.value === 'false' || display.value === 'true' || display.value === '1' || display.value === '0') { - display.value = '0.4.0'; - } - if (display && display.value && currentVersion && semver.gt(display.value, currentVersion)) { return display.value; }