Bug 1742839 - Improve handling of missing last modified dates in remote settings database. r=robwu,leplatrem

Differential Revision: https://phabricator.services.mozilla.com/D132053
This commit is contained in:
Mark Banner 2021-11-30 10:11:50 +00:00
Родитель 94a260ca9b
Коммит 4d26cd3ddd
2 изменённых файлов: 25 добавлений и 1 удалений

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

@ -177,7 +177,17 @@ class Database {
this.identifier
);
}
return entry ? entry.value : null;
if (!entry) {
return null;
}
// Some distributions where released with a modified dump that did not
// contain timestamps for last_modified. Work around this here, and return
// the timestamp as zero, so that the entries should get updated.
if (isNaN(entry.value)) {
console.warn(`Local timestamp is NaN for ${this.identifier}`);
return 0;
}
return entry.value;
}
async getMetadata() {

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

@ -117,6 +117,20 @@ add_task(async function test_load_dump_after_non_empty_import() {
});
add_task(clear_state);
add_task(async function test_load_dump_after_import_from_broken_distro() {
// Dump is updated regularly, verify that the dump matches our expectations
// before running the test.
ok(DUMP_LAST_MODIFIED > 1234, "Assuming dump to be newer than dummy 1234");
// No last_modified time.
await importData([{ id: "dummy" }]);
const after = await client.get({ loadDumpIfNewer: true });
equal(after.length, DUMP_RECORDS.length, "Imported dump");
equal(await client.getLastModified(), DUMP_LAST_MODIFIED, "dump's timestamp");
});
add_task(clear_state);
add_task(async function test_skip_dump_if_same_last_modified() {
await importData([{ last_modified: DUMP_LAST_MODIFIED, id: "dummy" }]);