Skip to content

pito-fetch

A terminal: get downloads model.bin from a local server with a progress bar and is stopped with Ctrl-C at 54%, leaving model.bin.part; the same command again resumes from 54% and prints models/model.bin; with a wrong sha256 it prints a checksum mismatch, and ls shows only model.bin.

Downloads you can trust, in one call. pito-fetch is a small Rust library, part of PITO MD: give it a URL, where the file goes and the file’s sha256. It downloads into a .part file, picks that file up again after a crash or a dropped connection, checks the sha256 and only then renames it into place. A file is there whole and verified, or not at all.

1 GiB downloaded and verified 2.47 s on loopback, in 7.8 MiB of memory
Library code 699 lines of Rust
Dependencies 3 direct (ureq, sha2, thiserror), no OpenSSL or other system library
Clean release build 11.7 s
A downloader built on it 2.5 MB stripped, TLS and root certificates included

Speed and memory says how each number was measured. Works on Linux and macOS (Windows through WSL).

The code is MIT licensed, © Catalin Ilinca. The pito-fetch and PITO MD names and their logos are © Catalin Ilinca, all rights reserved, and are not covered by the MIT licence. Source and issues: github.com/gmrdad82/pito-fetch.