diff --git a/tools/catalog-base.js b/tools/catalog-base.js index 8596dc2b47..944de4956d 100644 --- a/tools/catalog-base.js +++ b/tools/catalog-base.js @@ -15,9 +15,6 @@ var files = require('./files.js'); var baseCatalog = exports; -// XXX "Meteor-Core"? decide this pre 0.9.0. -baseCatalog.DEFAULT_TRACK = 'METEOR-CORE'; - // This is a basic catalog class. It accesses basic catalog data by looking // through the catalog's collections. // @@ -34,6 +31,9 @@ baseCatalog.BaseCatalog = function () { self.releaseTracks = null; self.releaseVersions = null; + // XXX "Meteor-Core"? decide this pre 0.9.0. + self.DEFAULT_TRACK = 'METEOR-CORE'; + // We use the initialization design pattern because it makes it easier to use // both of our catalogs as singletons. self.initialized = false; @@ -196,6 +196,10 @@ _.extend(baseCatalog.BaseCatalog.prototype, { // them. Depending on when we build them, we can refer to local packages as // 1.0.0+local or 1.0.0+[buildId]. Luckily, we know which packages are // local, so just look those up by their local version instead. + // XXX ideally we'd only have isLocalPackage in the complete catalog and + // have CompleteCatalog override getVersion, but other things want + // to call isLocalPackage, eg maybeDownloadPackageForArchitectures + // which has the official package when running make-bootstrap-tarballs if (self.isLocalPackage(name)) { version = self._getLocalVersion(version); } @@ -206,6 +210,13 @@ _.extend(baseCatalog.BaseCatalog.prototype, { }); }, + // Overridden by CompleteCatalog. + // XXX this is kinda sketchy, maybe callers should only call this + // on the CompleteCatalog? + isLocalPackage: function () { + return false; + }, + // As getVersion, but returns info on the latest version of the // package, or null if the package doesn't exist or has no versions. getLatestVersion: function (name) { @@ -281,9 +292,9 @@ _.extend(baseCatalog.BaseCatalog.prototype, { self._requireInitialized(); return self._recordOrRefresh(function () { - _.findWhere(self.builds, - { versionId: versionRecord._id, - architecture: archesString }); + return _.findWhere(self.builds, + { versionId: versionRecord._id, + architecture: archesString }); }); }, @@ -302,16 +313,18 @@ _.extend(baseCatalog.BaseCatalog.prototype, { // default track. Returns null if no such thing exists (even after syncing // with the server, which it only does if there is no eligible release // version). - getDefaultReleaseVersion: function () { + getDefaultReleaseVersion: function (track) { var self = this; self._requireInitialized(); + if (!track) + track = self.DEFAULT_TRACK; + var getDef = function () { - var versions = self.getSortedRecommendedReleaseVersions( - self.DEFAULT_TRACK); + var versions = self.getSortedRecommendedReleaseVersions(track); if (!versions.length) return null; - return {track: self.DEFAULT_TRACK, version: versions[0]}; + return {track: track, version: versions[0]}; }; return self._recordOrRefresh(getDef); diff --git a/tools/run-updater.js b/tools/run-updater.js index 204ea13555..d5f429ff75 100644 --- a/tools/run-updater.js +++ b/tools/run-updater.js @@ -35,6 +35,8 @@ _.extend(Updater.prototype, { updater.tryToDownloadUpdate({showBanner: true}); } catch (e) { // oh well, this was the background. no need to show any errors. + // XXX but during development we are + console.log("XXX updater error", e, e.stack); return; } }, diff --git a/tools/service-connection.js b/tools/service-connection.js index f213db454b..1979c2ac78 100644 --- a/tools/service-connection.js +++ b/tools/service-connection.js @@ -83,6 +83,8 @@ _.extend(ServiceConnection.prototype, { var fut = new Future; self._onConnectionTimeout(function () { fut['throw'](new ServiceConnection.ConnectionTimeoutError); + // XXX should also disable fut somehow so we don't get a "more than once" + // error later }); var args = _.toArray(arguments); diff --git a/tools/tropohouse.js b/tools/tropohouse.js index 372768584c..1f29012a43 100644 --- a/tools/tropohouse.js +++ b/tools/tropohouse.js @@ -188,13 +188,13 @@ _.extend(exports.Tropohouse.prototype, { latestMeteorSymlink: function () { var self = this; - var path = path.join(self.root, 'meteor'); - return fs.readlinkSync(path); + var linkPath = path.join(self.root, 'meteor'); + return fs.readlinkSync(linkPath); }, replaceLatestMeteorSymlink: function (linkText) { var self = this; - var path = path.join(self.root, 'meteor'); - files.symlinkOverSync(linkText, path); + var linkPath = path.join(self.root, 'meteor'); + files.symlinkOverSync(linkText, linkPath); } }); diff --git a/tools/updater.js b/tools/updater.js index fd16d44e87..97061eab76 100644 --- a/tools/updater.js +++ b/tools/updater.js @@ -1,4 +1,5 @@ var path = require('path'); +var _ = require('underscore'); var inFiber = require('./fiber-helpers.js').inFiber; var files = require('./files.js'); var tropohouse = require('./tropohouse.js'); @@ -33,17 +34,23 @@ exports.tryToDownloadUpdate = function (options) { var checkForUpdate = function (showBanner) { // XXX we should ignore errors here, right? but still do the "can we update // this app with a locally available release" check. - catalog.serverCatalog.refresh(true); + catalog.official.refresh(); - if (!release.isProperRelease()) + if (!release.current.isProperRelease()) return; - var currentReleaseTrack = release.current.getTrack(); - var latestRelease = catalog.serverCatalog.getDefaultRelease( + var currentReleaseTrack = release.current.getReleaseTrack(); + var latestReleaseVersion = catalog.official.getDefaultReleaseVersion( currentReleaseTrack); // Maybe you're on some random track with nothing recommended. That's OK. - if (!latestRelease) + if (!latestReleaseVersion) return; + + var latestRelease = catalog.official.getReleaseVersion( + latestReleaseVersion.track, latestReleaseVersion.version); + if (!latestRelease) + throw Error("latest release doesn't exist?"); + var latestReleaseToolParts = latestRelease.tool.split('@'); var latestReleaseToolPackage = latestReleaseToolParts[0]; var latestReleaseToolVersion = latestReleaseToolParts[1]; @@ -51,7 +58,7 @@ var checkForUpdate = function (showBanner) { latestReleaseToolPackage, latestReleaseToolVersion, true); var localLatestReleaseLink = tropohouse.default.latestMeteorSymlink(); - if (utils.startsWith(localLatestReleaseLink, relativeToolPath + path.sep)) { + if (!utils.startsWith(localLatestReleaseLink, relativeToolPath + path.sep)) { // The latest release from the catalog is not where the ~/.meteor0/meteor // symlink points to. Let's make sure we have that release on disk, // and then update the symlink. @@ -73,7 +80,7 @@ var checkForUpdate = function (showBanner) { throw Error("latest release has no tool?"); console.log("XXX updating tool symlink for", - latestRelease.track + "@" + latestRelease.version); + latestReleaseVersion.track + "@" + latestReleaseVersion.version); tropohouse.default.replaceLatestMeteorSymlink( path.join(relativeToolPath, toolRecord.path, 'meteor'));