1# @ajax/mesh-blobs-durable
23Blob files made durable. The bytes are written to `name.tmp`, fsynced and renamed, so a blob is
4either whole under its name or absent (a crash leaves at most a `.tmp`). The rename is durable once
5the directory is fsynced, and the writers batch that. A job's copy of bytes another job already
6holds is a hard link of that file, so the bytes are on disk once. If the linked file went meanwhile
7(its job forgotten), the bytes are written instead. This uses fsync(2), not a drive-cache flush
8(macOS's `F_FULLFSYNC`), which is the job log's guarantee too.
910## Ported from
1112[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT):
13`crates/mesh-host/src/blobs.rs`: `make_durable`, `write_durable`, `sync_dir`, `fsync`.
1415## Tests
1617`tests/durable.c`: whole files with no `.tmp` left, links sharing an inode, relinking over a name, a
18vanished link source written instead, a failing directory sync, `mb_remove_tree`.
1920## Licence
2122MIT. See the repository's LICENSE.