Expand description
A download’s own thread, which handles everything that happens to it, in order: its connections’ progress, and what the app asks of it.
A download asked to use several connections asks for the whole file as a range. A server that answers with part of it and the file’s size gets the file split into parts, each fetched by its own connection into its own place in the partial file: the first connection keeps the first part, and new ones ask for the rest. Any other answer leaves one connection fetching the whole file.
Pausing closes each connection’s outlet and keeps the partial file; resuming opens a new connection for each part not yet saved, asking for the rest of it with an HTTP range request. A server that ignores the range sends the whole file again, so a download with one connection starts over from its first byte.
A connection that fails in a way that may pass is tried again the same way, after a wait the thread spends listening for events, so the app can pause or cancel meanwhile.
Modules§
- stopped 🔒
- How a download stops other than by being saved, and why one fails.
Structs§
- Abandoned 🔒
- The UI thread is gone, so nobody is waiting for this download any more.
- Download 🔒
- A download in progress, as its own thread sees it.
- Job 🔒
- What a download fetches, where it saves it, and how many connections it may open.
Enums§
- Event 🔒
- Something that happened to a download.
Constants§
- REPORT_
INTERVAL 🔒 - How often progress is reported while data arrives, so a fast download doesn’t flood the UI thread with updates nobody can see.
Functions§
- run 🔒
- Runs
job, handlingeventsuntil it ends, and sending each step toreport.connectis where its connections send their events.