Parallel Downloader ๐ฆ
A robust, concurrent file downloader built in Rust. It is designed to be resilient, supporting automatic retries, crash recovery, and download verification.
๐ Features
- Concurrency: Downloads files in parallel chunks to maximize bandwidth.
- Resiliency: Automatically retries failed chunks on network timeouts.
- Crash Recovery: Saves progress to a state file (
.state.json). If the program crashes or is interrupted, simply run the command again to resume exactly where it left off. - Rate Limiting: Optional token-bucket throttling to limit bandwidth usage.
- Integrity Check: Verifies the final file against a SHA-256 hash.
- Library Support: Logic is separated from the CLI, allowing you to use the core downloader in your own Rust applications.
๐ฆ Installation
Ensure you have Rust installed. Clone the repository and build:
The binary will be located in ./target/release/parallel_downloader
๐ Usage
Basic Download
Download a file with default settings (4 threads).
Advanced Usage
Combine flags for a specific use case:
Options
| Flag | Description | Default |
|---|---|---|
--url |
The URL to download | Required |
--output, -o |
Output filename | output.bin |
--threads, -t |
Number of concurrent threads | 4 |
--rate-limit |
Max speed in bytes/sec (e.g., 1048576 = 1MB/s) | Unlimited |
--verify-sha256 |
Hash string to verify file integrity | None |
๐ Library Usage
You can use parallel_downloader as a library in your own project.
Add to your Cargo.toml:
[dependencies]
parallel_downloader = { path = "../path/to/parallel_downloader" }
Use the modules in your code:
use get_file_size;
use download_chunk;
async
๐งช Testing
Run the test suite, which includes unit tests for math/hashing and integration tests using a mock HTTP server.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.