feat: resume an interrupted download instead of refetching it (#18)
Downloads buffered the whole file in memory and wrote it out only on success, so an interrupted transfer left nothing behind and always started over. The START_DOWNLOAD offset was hardcoded to zero on the download side and discarded on the upload side, so neither half of the protocol's resume support was wired up. Bytes now stream into `<file>.part` as they arrive and it is renamed only once the file is whole. A new attempt sends the partial file's length as the START_DOWNLOAD offset, and `serve_file` seeks to the offset a peer asks for rather than replaying from the start. A `.part` at or past the expected size is treated as stale and restarted. Partial files are kept out of the share index, since the download directory is shared by default.
This commit is contained in:
@@ -29,6 +29,8 @@ does, how to install it, and every `config.toml` setting.
|
||||
- **Sharing**: `shares add` a directory and your files show up in searches;
|
||||
`serve` stays online so peers can browse and download them
|
||||
- **Browse**: list any user's shared files and download straight from the tree
|
||||
- **Resumable downloads**: a transfer that dies leaves a `.part` file, and
|
||||
re-running the download asks the peer to send only what is missing
|
||||
- **Chat rooms**: list, join, and talk in public rooms, several open at once
|
||||
- **Private messages**: send and receive messages, with an inbox in the TUI
|
||||
- **Firewalled peers**: downloads and browsing fall back to server-brokered
|
||||
@@ -327,6 +329,12 @@ there yet.
|
||||
Downloads run under a deadline (`--timeout`, 300s by default) and
|
||||
`--max-concurrent-downloads` at a time, so an unattended run always ends.
|
||||
|
||||
An interrupted download is picked up where it stopped. Bytes stream into
|
||||
`<file>.part` as they arrive and it is renamed only once the file is whole, so
|
||||
re-running the same `download` asks the peer to start at the offset already on
|
||||
disk. Partial files are never offered to other peers, and deleting the `.part`
|
||||
starts the transfer over.
|
||||
|
||||
### Configuration
|
||||
|
||||
Every setting can come from a flag, an environment variable, or the config
|
||||
|
||||
Reference in New Issue
Block a user