diff --git a/packages/autoupdate/autoupdate_server.js b/packages/autoupdate/autoupdate_server.js index 843a694a6f..5219e1d150 100644 --- a/packages/autoupdate/autoupdate_server.js +++ b/packages/autoupdate/autoupdate_server.js @@ -51,6 +51,7 @@ ClientVersions = new Meteor.Collection("meteor_autoupdate_clientVersions", Autoupdate.autoupdateVersion = null; Autoupdate.autoupdateVersionRefreshable = null; +Autoupdate.autoupdateVersionCordova = null; var syncQueue = new Meteor._SynchronousQueue(); var startupVersion = null; @@ -78,6 +79,12 @@ var updateVersions = function (shouldReloadClientProgram) { process.env.SERVER_ID || // XXX COMPAT 0.6.6 WebApp.calculateClientHashRefreshable(); + Autoupdate.autoupdateVersionCordova = + __meteor_runtime_config__.autoupdateVersionCordova = + process.env.AUTOUPDATE_VERSION || + process.env.SERVER_ID || // XXX COMPAT 0.6.6 + WebApp.calculateClientHashCordova(); + // Step 2: form the new client boilerplate which contains the updated // assets and __meteor_runtime_config__. if (shouldReloadClientProgram) { @@ -109,6 +116,18 @@ var updateVersions = function (shouldReloadClientProgram) { assets: WebAppInternals.refreshableAssets }}); } + + if (! ClientVersions.findOne({_id: "version-cordova"})) { + ClientVersions.insert({ + _id: "version-cordova", + version: Autoupdate.autoupdateVersionCordova, + refreshable: false + }); + } else { + ClientVersions.update("version-cordova", { $set: { + version: Autoupdate.autoupdateVersionCordova + }}); + } }); }; diff --git a/packages/webapp/webapp_server.js b/packages/webapp/webapp_server.js index f7d4461033..84036e99df 100644 --- a/packages/webapp/webapp_server.js +++ b/packages/webapp/webapp_server.js @@ -182,12 +182,16 @@ var appUrl = function (url) { // (but the second is a performance enhancement, not a hard // requirement). -var calculateClientHash = function (manifest, includeFilter) { +var calculateClientHash = function (manifest, includeFilter, skipRuntimeCfg) { var hash = crypto.createHash('sha1'); - // Omit the old hashed client values in the new hash. These may be - // modified in the new boilerplate. - hash.update(JSON.stringify(_.omit(__meteor_runtime_config__, - ['autoupdateVersion', 'autoupdateVersionRefreshable']), 'utf8')); + + if (! skipRuntimeCfg) { + // Omit the old hashed client values in the new hash. These may be + // modified in the new boilerplate. + var runtimeCfgString = _.omit(__meteor_runtime_config__, + ['autoupdateVersion', 'autoupdateVersionRefreshable']); + hash.update(JSON.stringify(runtimeCfgString, 'utf8')); + } _.each(manifest, function (resource) { if ((! includeFilter || includeFilter(resource.type)) && (resource.where === 'client' || resource.where === 'internal')) { @@ -236,6 +240,16 @@ Meteor.startup(function () { return name !== "css"; }); }; + WebApp.calculateClientHashCordova = function () { + var archName = 'web.cordova'; + if (! WebApp.clientPrograms[archName]) + return 'none'; + + return calculateClientHash( + WebApp.clientPrograms[archName].manifest, + function () { return true; }, + true); + }; });