Bug 1174956 - Allow device to be up to one week newer than client. r=ochameau

This commit is contained in:
J. Ryan Stinnett 2015-06-24 22:15:48 -07:00
Родитель c08cb8180c
Коммит 7094b8e805
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -36,6 +36,8 @@ const HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Troubleshootin
const MAX_ZOOM = 1.4;
const MIN_ZOOM = 0.6;
const MS_PER_DAY = 86400000;
// Download remote resources early
getJSON("devtools.webide.addonsURL", true);
getJSON("devtools.webide.templatesURL", true);
@ -932,6 +934,12 @@ let UI = {
this.updateProjectEditorMenusVisibility();
},
buildIDToDate(buildID) {
let fields = buildID.match(/(\d{4})(\d{2})(\d{2})/);
// Date expects 0 - 11 for months
return new Date(fields[1], Number.parseInt(fields[2]) - 1, fields[3]);
},
checkRuntimeVersion: Task.async(function* () {
if (AppManager.connected && AppManager.deviceFront) {
let desc = yield AppManager.deviceFront.getDescription();
@ -940,7 +948,12 @@ let UI = {
// warning against builds of the same day.
let deviceID = desc.appbuildid.substr(0, 8);
let localID = Services.appinfo.appBuildID.substr(0, 8);
if (deviceID > localID) {
let deviceDate = this.buildIDToDate(deviceID);
let localDate = this.buildIDToDate(localID);
// Allow device to be newer by up to a week. This accommodates those with
// local device builds, since their devices will almost always be newer
// than the client.
if (deviceDate - localDate > 7 * MS_PER_DAY) {
this.reportError("error_runtimeVersionTooRecent", deviceID, localID);
}
}