Skip to main content
Checksums lets a VFS answer hash commands from a hash its service already stores, without reading the file. Built-in VFSs lists which VFSs support it.

VFS and Checksums Integration

A VFS overrides checksum when its service stores hashes. It returns None (TypeScript: null) when it has no stored hash, and Mirage reads and hashes the file instead. The example extends NotesVFS from Adding a New VFS, mounted at /notes.

checksum

The stored hash of one file. Commands: md5sum, md5, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum and b2sum. With -c, which checks the hashes listed in a file, they read the files without asking.
PathSpec
required
The file, on this mount.
str
required
The hash to return: md5, sha1, sha224, sha256, sha384, sha512, blake2b, or blake2b-N for BLAKE2b at N bits.
Examples:
str | None
A real service returns the hash it stores. This example computes MD5 and leaves the others to Mirage, so md5sum /notes/hello.txt reads nothing, and sha256sum /notes/hello.txt still reads the page.