This page provides an overview of how download resumption is implemented
Resuming downloads is a useful feature that saves bandwidth and time by allowing the retrieval process to continue from where it left off, in case of interruptions or disconnections.
It calculates where to restart by determining the startBlock when processing download requests. This computation occurs in the calculateShardParams method, which interacts with the fileHandler to establish the file size. The derived size is then employed to call the Seek() method of the DownloadRequest. This method adjusts the offset field of the DownloadRequest, which is subsequently used to calculate the startBlock.
For local files, the system opens them in append mode if the file already exists and has a size that's greater than 0.
This resumption feature is illustrated in the code sections below. These functions together facilitate the operation of the download resumption process:
calculateShardsParams(): Executes the actual resumption logic by calculating shard parameters. If there's an offset (indicating an existing incomplete file), it adjusts the startBlock accordingly.