Slowpoke101/FTBLaunch — pull request #630 by Viper-7 (2014-01-08 03:30:10+00:00)
Title: RFC: Simple resume support for pack downloads

Instead of simply throwing an error message and aborting the entire 100+mb pack download when a user's internet drops out for a moment, I propose to let the launcher try to open a new connection, which will resume the download from the point it dropped out.

This will not allow users to cancel a pack download and resume it later, but it will hopefully completely resolve download issues for those with unreliable internet connections.

This is easily implemented using the Range header built into HTTP 1.1, and is fully supported by the CreeperHost/CreeperRepo servers.

My attached implementation will constantly retry the download as long as more data has been received since the last attempt, so for intermittent connections that may drop hundreds of times through the process, we won't give up as long as we're making headway.

It has a hard limit of 5 retries if no data has been received since the last attempt. This is to stop the downloader getting stuck in an infinite loop and users needing to end process it to cancel the download.

It will also check on each retry that the amount of data being sent (which should be the remainder of the pack archive), when added to the amount of data already stored, is equal to the expected total size of the pack archive. This means that if corruption does happen to occur during the resume process, it will likely be caught before any further data is downloaded, which will avoid wasting any more of the user's time.

The timeouts already in use by the launcher are 14 seconds for a connection, and 20 seconds for reading data. I haven't changed these. This means that if a user's connection drops mid-download, the progress bar will stall for a maximum of 90 seconds before aborting (20 seconds for a read timeout, then 14 seconds per connection attempt for 5 retries). If the user tries to launch again, the download will not be resumed, and they will re-download the entire archive.