mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 917965 - Don't apply or save invalid updates. r=fabrice
This commit is contained in:
parent
77f252b75d
commit
b2443a55c5
@ -95,7 +95,13 @@ this.UserAgentUpdates = {
|
||||
let file = FileUtils.getFile(dir, [FILE_UPDATES], true).path;
|
||||
// tryNext returns promise to read file under dir and parse it
|
||||
let tryNext = () => OS.File.read(file).then(
|
||||
(bytes) => JSON.parse(gDecoder.decode(bytes))
|
||||
(bytes) => {
|
||||
let update = JSON.parse(gDecoder.decode(bytes));
|
||||
if (!update) {
|
||||
throw new Error("invalid update");
|
||||
}
|
||||
return update;
|
||||
}
|
||||
);
|
||||
// try to load next one if the previous load failed
|
||||
return prevLoad ? prevLoad.then(null, tryNext) : tryNext();
|
||||
@ -170,7 +176,10 @@ this.UserAgentUpdates = {
|
||||
request.overrideMimeType("application/json");
|
||||
request.responseType = "json";
|
||||
|
||||
request.addEventListener("load", function() success(request.response));
|
||||
request.addEventListener("load", function() {
|
||||
let response = request.response;
|
||||
response ? success(response) : error();
|
||||
});
|
||||
request.addEventListener("error", error);
|
||||
request.send();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user