future.wrap on get_manifest didn't work (bad callback type).

just make it sync instead.
This commit is contained in:
David Glasser
2013-03-05 11:55:23 -08:00
parent aa105b7c8a
commit 00d250c376
5 changed files with 34 additions and 56 deletions

View File

@@ -370,7 +370,8 @@ Fiber(function () {
process.exit(1);
}
require(path.join(__dirname, 'update.js'));
var update = require(path.join(__dirname, 'update.js'));
update.updateMeteor();
}
});

View File

@@ -497,20 +497,25 @@ _.extend(DependencyWatcher.prototype, {
// XXX this should move to main meteor command-line, probably?
var start_update_checks = function () {
var update_check = function () {
updater.get_manifest(function (manifest) {
if (!files.in_checkout() && manifest &&
updater.needs_upgrade(manifest)) {
console.log("////////////////////////////////////////");
console.log("////////////////////////////////////////");
console.log();
console.log("meteor is out of date. Please run:");
console.log();
console.log(" meteor update");
console.log();
console.log("////////////////////////////////////////");
console.log("////////////////////////////////////////");
}
});
// XXX update for engine
try {
var manifest = updater.getManifest();
} catch (e) {
// Ignore errors (eg, offline)
return;
}
if (!files.in_checkout() && manifest &&
updater.needs_upgrade(manifest)) {
console.log("////////////////////////////////////////");
console.log("////////////////////////////////////////");
console.log();
console.log("meteor is out of date. Please run:");
console.log();
console.log(" meteor update");
console.log();
console.log("////////////////////////////////////////");
console.log("////////////////////////////////////////");
}
};
setInterval(update_check, 12*60*60*1000); // twice a day
update_check(); // and now.

View File

@@ -19,8 +19,11 @@ if (files.in_checkout()) {
process.exit(1);
}
// Immediately kick off manifest check.
updater.get_manifest(function (manifest) {
// XXX update for engine
var updateMeteor = function () {
// Immediately kick off manifest check.
// XXX error check
var manifest = updater.getManifest();
//// Examine manifest and see if we need to upgrade.
@@ -248,4 +251,4 @@ updater.get_manifest(function (manifest) {
});
req.end();
});
};

View File

@@ -9,52 +9,21 @@ var http = require("http");
var https = require("https");
var path = require("path");
var semver = require("semver");
var Future = require('fibers/future');
var files = require(path.join(__dirname, 'files.js'));
var manifest_options = testingUpdater ? {
host: 's3.amazonaws.com',
path: '/com.meteor.static/test/update/manifest.json'
} : {
host: 'update.meteor.com',
path: '/manifest.json'
};
var manifestUrl = testingUpdater
? 'https://s3.amazonaws.com/com.meteor.static/test/update/manifest.json'
: 'https://update.meteor.com/manifest.json';
/**
* Downloads the current manifest file and returns it via a callback (or
* null on error)
*/
// XXX make this synchronous
exports.get_manifest = function (callback) {
// XXX this is gross. use files.getUrl instead.
var req = https.request(manifest_options, function(res) {
if (res.statusCode !== 200) {
callback(null);
return;
}
res.setEncoding('utf8');
var manifest = '';
res.on('data', function (chunk) {
manifest = manifest + chunk;
});
res.on('end', function () {
var parsed;
try {
parsed = JSON.parse(manifest);
} catch (err) {
parsed = null;
};
callback(parsed);
});
});
req.addListener('error', function (err) {
// Need to register an error handler or node will crash:
// http://rentzsch.tumblr.com/post/664884799/node-js-handling-refused-http-client-connections
callback(null);
});
req.end();
exports.getManifest = function () {
return Future.wrap(files.getUrl)({url: manifestUrl, json: true});
};
/**

View File

@@ -95,7 +95,7 @@ var warehouse = module.exports = {
// XXX make errors prettier
fetchLatestRelease: function () {
var manifest = Future.wrap(updater.get_manifest)().wait();
var manifest = updater.getManifest();
// XXX in the future support release channels other than stable
var releaseName = manifest.releases.stable;
if (!releaseName) {