gecko-dev/services
Rob Wu e515fb95e2 Bug 1620621 - Add caching and recovery mechanisms to RemoteSettings's download() method r=Gijs,leplatrem
The current RemoteSettings API has two methods for downloading:

- `download(record)` to download an attachment to disk, with a filename
  given by the record. The file is read and returned before downloading.
  A new download attempt overwrites the file, with no recovery mechanism
  if the download fails.
- `downloadAsBytes(record)` to download an attachment in memory.

The `download` method does have a cache, but it is only useful for
reducing bandwidth usage, not for availability of data. Moreover, if its
associated record is removed from the collection, then callers do not
have a way to delete the file since its identifier (filename) originates
from the record.

The `downloadAsBytes` method does not have this file tracking issue
since it does not persist the data, but it forces callers to implement
their own attachment storing mechanism.

This commit adds the `useCache` option to the `download()` method to
enable callers to use an IndexedDB-based cache instead of the
filesystem. The following options unlock significant features:

- `fallbackToCache` - If the requested attachment is not available, the
  last known attachment is returned.
- `fallbackToDump` - If the requested attachment is not available, nor
  cached, then the attachment (dump) that is packaged with the client is
  returned instead. This is implemented in the next commit (D72417).

The original record is cached along with the attachment, to allow
callers to use the file (identified by the given `attachmentId`) and
its metadata, even when the original record has been removed from the
collection.

This is particularly useful for scenarios where one wants to keep a file
(and metadata) up to date via RemoteSettings, without having to develop
a separate storage and synchronization mechanism.

The deprecation of the old behavior will be handled in bug 1634127.

Differential Revision: https://phabricator.services.mozilla.com/D72416
2020-04-30 09:02:14 +00:00
..
automation Bug 1622328 - add license info to all eslintrc files r=Standard8,webcompat-reviewers,miketaylr 2020-03-19 13:47:51 +00:00
common Bug 1620621 - Add caching and recovery mechanisms to RemoteSettings's download() method r=Gijs,leplatrem 2020-04-30 09:02:14 +00:00
crypto Bug 1622666 - Removes redundant access specifier r=froydnj 2020-03-22 11:58:15 +00:00
fxaccounts Bug 1604844 - add identifiers from the sync ping to the deletion-request ping. r=markh,chutten 2020-04-29 07:47:38 +00:00
interfaces Bug 1596322 - Add XPCOM bindings for Rust Sync engines. r=markh,tcsc,LougeniaBailey 2020-04-09 15:45:37 +00:00
settings Bug 1620621 - Add caching and recovery mechanisms to RemoteSettings's download() method r=Gijs,leplatrem 2020-04-30 09:02:14 +00:00
sync Bug 1634257 - expose wipe_all to mozIExtensionStorageArea. r=lina 2020-04-30 08:16:26 +00:00
moz.build Bug 1596322 - Add XPCOM bindings for Rust Sync engines. r=markh,tcsc,LougeniaBailey 2020-04-09 15:45:37 +00:00