Skip to content

Commit

Permalink
1.11b.rev2
Browse files Browse the repository at this point in the history
* If time server is down i report that now
  • Loading branch information
Noitidart committed May 18, 2016
1 parent ee5eb93 commit da7c37b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ var MainWorkerMainThreadFuncs = {
}
}
];
} else if (aLocalizedKey == 'attn-failed-signing' || aLocalizedKey == 'attn-failed-signing-not-logged-in' || aLocalizedKey == 'attn-failed-signing-didnt-agree') {
} else if (aLocalizedKey == 'attn-failed-signing' || aLocalizedKey == 'attn-failed-signing-not-logged-in' || aLocalizedKey == 'attn-failed-signing-didnt-agree' || aLocalizedKey == 'attn-failed-signing-time-server') {
aAttnBarInfoObj.aBtns = [];
aAttnBarInfoObj.aBtns.push({
bTxt: justFormatStringFromName(gL10N.bootstrap['install-as-temp']),
Expand Down
3 changes: 2 additions & 1 deletion locale/en-US/bootstrap.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ attn-failed-signing-not-logged-in=In order to sign the addon, you need to have a
open-amo=Open Login - addons.mozilla.org
retry=Retry
open-agree=Open Agreement - addons.mozilla.org
attn-failed-signing-didnt-agree=In order to sign the addon, you must have agreed to the agreement
attn-failed-signing-didnt-agree=In order to sign the addon, you must have agreed to the agreement
attn-failed-signing-time-server=The server from which time is fetched, is currently down
24 changes: 22 additions & 2 deletions modules/MainWorker/MainWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP
}
}

function getNowDateFromServer() {
function getNowDateFromServer(aTryCnt) {
if (!aTryCnt) {
aTryCnt = 0;
}
var requestStartDate = Date.now();

var requestUnixNow = xhr('http://currenttimestamp.com/');
Expand All @@ -378,10 +381,19 @@ function getNowDateFromServer() {
console.log('request took:', requestDuration, 'ms');

if (requestUnixNow.status != 200) {
if (aTryCnt > 4) {
throw {
msg: 'signing-failed:time server down',
xhr: {
status: requestUnixNow.status,
response: requestUnixNow.response,
}
};
}
console.log('response status was bad, will wait 5 sec then try again');
setTimeoutSync(5000);
console.log('ok waitied, will now try');
return getNowDateFromServer();
return getNowDateFromServer(aTryCnt + 1);
}

console.log('requestUnixNow.status:', requestUnixNow.status);
Expand Down Expand Up @@ -557,6 +569,11 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) {
}
};

// the persistent property is not reconized by firefox, and it will break it
if (manifestContentsJSON.background && manifestContentsJSON.background.persistent) {
delete manifestContentsJSON.background.persistent;
}

// write/overwrite with modified manifest.json back to zip
zipJSZIP.file('manifest.json', JSON.stringify(manifestContentsJSON));

Expand Down Expand Up @@ -684,6 +701,9 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) {
} else if (ex.msg == 'signing-failed:didnt agree') {
aLocalizedKey = 'attn-failed-signing-didnt-agree';
aAttnBarInstState.aTxt = formatStringFromName(aLocalizedKey, 'bootstrap', [aExtName]);
} else if (ex.msg == 'signing-failed:time server down') {
aLocalizedKey = 'attn-failed-signing-time-server';
aAttnBarInstState.aTxt = formatStringFromName(aLocalizedKey, 'bootstrap', [aExtName]);
} else {
aLocalizedKey = 'attn-failed-signing';
aAttnBarInstState.aTxt = formatStringFromName(aLocalizedKey, 'bootstrap', [aExtName]);
Expand Down

0 comments on commit da7c37b

Please sign in to comment.