Download Engine
The dlman-core crate is the heart of DLMan. It handles all download operations and is shared between the desktop app and CLI.
Multi-Segment Downloads
When you download a file, DLMan splits it into multiple segments that download in parallel. Each segment uses its own HTTP connection with a Range header, writing directly to the correct file offset.
Segment Sizing
Segment count is automatically calculated based on file size:
| File Size | Segments | Per Segment |
|---|---|---|
| < 1 MB | 1 | Full file |
| 1 – 10 MB | 2 | ~50% |
| 10 – 100 MB | 4 | ~25% |
| 100 MB – 1 GB | 8 | ~12.5% |
| > 1 GB | 16 | Variable |
Pause & Resume
Speed Limiting
DLMan uses a token bucket algorithm for smooth speed limiting. Tokens refill at the rate limit speed, and each segment must acquire tokens before downloading more data.
Per-download
Highest priority — overrides queue and global limits
Per-queue
Applied to all downloads in the queue
Global
App-wide limit across all downloads
Queue Scheduler
The QueueScheduler runs as a background task, checking schedules every 30 seconds. It automatically starts and stops queues based on configured times and active days.
Retry Policy
| Setting | Value |
|---|---|
| Max retries | 5 |
| Initial delay | 1s |
| Backoff | Exponential (1s, 2s, 4s, 8s, 16s) |
| Jitter | ±10% |
Error Handling
All operations return Result<T, DlmanError>. Errors are logged with context, saved to the download record, surfaced to the UI, and retried when possible.
NetworkIONotFoundInvalidUrlResumeNotSupportedDatabasePost-Download Actions
When a queue completes all downloads, these actions can trigger:
Send OS notification
Put computer to sleep
Shutdown the computer
Hibernate the computer
Execute a custom shell command