Open stoyicker opened 6 months ago
Thanks for your question!
I think not copying the progress information is on purpose. If a user is adding a DownloadRequest
with an existing ID again, then it is merged and in case of an adaptive stream, the new request may have different streamKeys
which means further data has to be downloaded from the beginning. When in such a case a Download
is attempted to be downloaded again, the process just starts again from the beginning and tries to find the cached data. If it's already in the cache, then it advances until it finds a cache miss that needs downloading. See [1] for where the stream keys are merged.
Accordingly, the progress is reset and when attempting to download again, the download would download additional tracks for an adaptive stream which starts from the beginning.
It looks like, given the stream keys are kept the same, the progress could be kept as well, assuming the media up to the progress will be found in the cache. The code isn't that clever to check this though.
I'm also not sure how save this is but I'd think that at least for Download
instances in a certain state (for instance excluding STATE_DOWNLOADING
and others), it would be save to keep the progress.
I'm marking this issue as an enhancement. I'm not sure when we get around looking into this. So I can't give you an idea on when that would be I'm afraid.
May I ask what the intention is of re-adding these downloads request?
Thanks, that clarifies things.
May I ask what the intention is of re-adding these downloads request?
I'd say that can be considered a bug on my end.
DownloadManager.mergeRequest
is used in certain cases when adding aDownload
toDownloadManager
. In my particular scenario, I re-add ongoing downloads from the index to DownloadManager when my app starts. The problem with this is that this ends up in the branch ofDownloadManager.addDownload
that callsDownloadManager.mergeRequest
. This returns aDownload
constructed using theDownload
constructor with the overload that does not have aDownloadRequest
, meaning that the returned Download representation has no recorded progress until a progress update happens - but since these ignore downloads in states other than downloading (seeDownloadManager.updateProgress
), I have no way of knowing if a download has progress until I resume it.I am not sure if this is a bug or just something I am misunderstanding.
Tested with pre-androidx 2.18.7 but from looking at
DownloadManager.updateProgress
in current tip of main (dc4f20e) I believe it's a situation probably present in there too.