Open akadatsky opened 8 years ago
maybe .setRetryPolicy(new DefaultRetryPolicy())? ThinDownloadManager has this.
Hi @JackLauu
Enven on main page noted: NOTE: Android's DownloadManager has plenty of features which is not available in ThinDownloadManager. For ex. pause and continue download when network connectivity changes.
Yes, DefaultRetryPolicy is in sample.
The problem is: if we lose connection, for example for 1 second, or server close connection on it side due to 502 or 503 error, it can't restart loading. Default DownloadManager can do it.
Android DownloadManager in this case at first sends partial content request, which return just size of file, and then start loading. If connection lost, it sends range request, something like this "Range: bytes=31246-58342" and continue to load from that place where it lost connection.
@akadatsky You are right. ThinDownloadManager doesn't keep track of how many bytes so far downloaded and if connection breaks it deletes the file which is not fully downloaded at the time. The general advice is if you are downloading a very large file in terms of 100MBs, stick with android download manager.
@smanikandan14 I can't due to of DOWNLOAD_WITHOUT_NOTIFICATION permission. I believe it's not hard to do in the technical plan, or ThinDownloadManager arch is not designed for this? Or you have no desire to maintain?
+1 for this feature
I may be implementing this depending on my current project requirements. I'll update this thread in the next couple weeks either way.
DownloadRequest can now be set to not delete files on download failure. It also supports html headers for setting range information. I am currently looking into whether this is all that is nessisary. If no changes are required, I'll post a few tips. Otherwise, I'll be implementing this.
There is a one line change required in ThinDownloadManager to enable resuming using the aforementioned headers. I will put together a quick pull request when I get to my computer later today. I will also post some example code in the pull request description.
See this pull request.
@PrimeKang How can we test this ? Any prescribed steps.
@smanikandan14
To test this pull request:
downloadRequest.addCustomHeader("Range", "bytes="+startByteZeroIndexed+"-"+endByteOrOmittedForEOF);
To test the sudocode I provided in the description of the pull request:
Any plans to support reconnect feature?