Choose the most recent attachment in the downloader as a fallback
Categories
(Firefox :: Remote Settings Client, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox78 | --- | fixed |
People
(Reporter: robwu, Assigned: robwu)
Details
Attachments
(3 files)
When the attachment downloader of the RemoteSettings client is unable to download the latest version of the attachment, it will optionally fall back to a previous version, either from the cache (last download from the network), or from the packaged dump.
The current implementation prioritizes the cached attachment over the packaged dump. We should compare the records' last_updated
fields and use the most recent of the two instead, so that clients who at some point had downloaded a copy of the attachment are able to use the latest packaged dump if somehow the remote settings server is unreachable.
And while we are at it, let do an optimization: let the client read the packaged dump before the cached dump, because those packaged attachments are expected to be up to date (otherwise there wouldn't really be a point in packaging them with Firefox).
Assignee | ||
Comment 1•5 years ago
|
||
In practice, the cache of the attachment downloader can become corrupt
and unusable when IndexedDB breaks. The implementation correctly handled
this case, but there were no tests that verified that it did.
This patch adds test coverage for the scenario of a broken cache,
to ensure that the implementation continues to behave in a sane way.
Assignee | ||
Comment 2•5 years ago
|
||
This commit does the following:
-
Feature / Optimization: Check the dump before the cache, instead of
the reverse. The dump is expected to match the requested attachment in
the common case, and checking it first helps with ensuring that the
expected (packaged dump) is used when available. -
Optimization: Defer reading the cached attachment until it's needed.
-
Refactor / Feature: Treat a missing
.meta.json
file as a sign that
the attachment dump does not exist, rather than an error.
Previously, if an attachment cannot be downloaded from the network,
that error would be replaced with a genericDownloadError
(from the
missing.meta.json
file). This is mostly relevant for telemetry. -
Refactor / Maintainability: Create helper to manage lazy access to the
record and attachment, to ensure that the record and attachment is
only read on demand, and at most once. -
Refactor / Readability: Move the common return value generation logic
to the helper asgetResult
, to avoid the verbose duplication of the
logic. Now the return value fits in one line instead of 5-6 lines. -
Fix test: Rename filename-of-dump.meta.json and fix test expectation
to ensure that the test checks the absence of the file content,
rather than the absence of the meta data file.
Assignee | ||
Comment 3•5 years ago
|
||
Comment 5•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0833992af392
https://hg.mozilla.org/mozilla-central/rev/32e4360d472a
https://hg.mozilla.org/mozilla-central/rev/96c36737f728
Description
•