derniercri / snatch

A simple, fast and interruptable download accelerator, written in Rust
MIT License
676 stars 37 forks source link

Implement the 'Interruptable' feature #32

Open k0pernicus opened 7 years ago

lambdaupb commented 7 years ago

axel has a state file which gets updated periodically while downloading. Upon restart axel can continue from the state last saved.

It would be enough to save the total file size and the remaining holes in the download to the status file.

daveallie commented 7 years ago

As an alternative to the state file approach, you could store the information in the first bytes of the downloading file, and give that file a custom file extension. The extension and download metadata would be stripped when the download completes. Here's a quick proposal for how it would work.

Limitations:

k0pernicus commented 7 years ago

I think that we should try different approaches, make some bench and take the one(s) that offer the best trade-off between a fast step "Retrying the download" and a great memory usage to store current file informations (and what to download next). Currently, we plan to improve and stabilize the "download" part, before to implement this feature - like, for example, switch to a mono-thread download when the server cannot give any informations about the remote content size, or try a strategy (for example using Divide and conquer algorithms) to "guess" the remote content sending header requests (like byte-ranges or something) and keep a close eye about the server's responses... :-)

daveallie commented 7 years ago

I played around with the idea I had above and built https://github.com/daveallie/grapple.

I made some changes to the proposal I had earlier:

Would be happy to give a more detailed explanation of how the 'restarting' phase works if you plan to go with the process I method above.