The controller should report the actual status of the downloads, let
the clients handle the special cases. Also, don't try to resume
downloads whose destination doesn't exist.
This partially reverts 7369e9cea9
("Set the status of paused downloads to unknown if no file exists").
This shouldn't really be necessary since the cleanup is needed after
the application data has been wiped, which by default has the
automatic updates check enabled.
The returned content-length depends on the requested range, therefore
when resuming download the reported size is smaller than the actual
file size and we should not update it.
The current argument is unused and it should have been removed
with commit 81229329f1
("Generate download clients using a builder class"). Instead of
removing it completely, use it to pass the File of the download.
In some cases, installing an update older than the one currently
installed requires a data wipe, so don't allow it. However, allow
to verify old updates if not verified yet (e.g. when imported).
This change allows to define a proper interface for the download
client and keep its implementation completely separate. It also
allows to create clients without starting the download right away,
which could be useful when defining callbacks that require a
reference to the client.
Note that this change also drops the unused methods of DownloadClient.
The files are supposed to be downloaded in a privileged location
that the user can't access. If the user wipes the data of the
application, the updates downloaded are not removed. Perform a
one-time cleanup so that our downloads dir doesn't grow without
control.
INCOMPLETE is used for any update that isn't verified, even if the
file has been completed. This change is mostly needed to support
imported downloads, which we take as complete, but unverified.
Each update must now be in updates.json to be downloaded. Since this
file already stores the URL of each update and that the URL is not
needed after the download, the URL entry can be removed from the
database.
This allows to properly update the status of the application.
In particular, when an update is deleted:
- Cancel the associated notification, if any.
- Remove the entry from the controller if the update is no longer
available online.
- Disable the resume button if download is partially downloaded
and is no longer available online.