Expand description
Notes and papers in the shared folder, one file at a time (docs/database.md,
“Notes and papers”). Each file is compressed (gzip), sealed in pieces
(XChaCha20-Poly1305), and kept once under a name made from its content:
blobs/<name>. A record in the log says which content each file holds
(share): a change sends that file alone, and a content in two places is
sent once. Written once, under a hidden name then renamed: any sync app
carries a new file. The folder’s server sees how big each is, never its
name nor what it holds.
Two keys of its own, made from the records’ key (HKDF-SHA-256): one seals the pieces, one names the files; the records’ key itself seals nothing here.
Never a whole file in memory: read, compressed and sealed a piece at a time, opened and written back the same way beside its place, and checked against its record before it takes that place.
Structs§
- Hashing 🔒
- What passes through, hashed and counted.
- Want
- A sealed file waited for.
- Wanted
- The sealed files of the others’ notes and papers this device waits for:
their records came, and the files they name are neither in the folder nor
fetched beside it yet (docs/database.md, “Sealed files fetched when
waited for”). The exchange says which (
share::exchange), the pull’s fetch brings them from the folder’s server (remote::fetch_wanted). Kept inshare/wanted.tomlbeside the sharing’s memory, never shared; none when nothing waits.
Enums§
- Fault
- Why a content could not be had from the folder.
Constants§
- AROUND 🔒
- A nonce and a tag around each piece.
- END 🔒
- In a piece’s length: the last one, which holds nothing and says the file ends there.
- INFLATED 🔒
- What is opened is inflated this much at a time: never far past
LARGEST. - LARGEST
- Files larger than this stay on their device.
- MAGIC 🔒
- How a sealed file begins.
- PIECE 🔒
- What is sealed at once.
- UNUSED_
DAYS - A sealed file no record points to any more is removed by its writer after this long.
Functions§
- begins 🔒
- A sealed file begins as one does.
- bound 🔒
- What a piece is bound to: its file, its place, and whether it is the end.
- check
- The sealed file at
pathopens whole to the contenthash, checked asgetchecks it, nothing written: a copy fetched is kept only so (remote::fetch_wanted). - fill 🔒
- As much as
readergives, up tobuffer’s length. - fingerprint
- What tells one copy of a file in the folder from another: its size, its time, and, where the system says, its place on the disk and when that changed (a copy brought again whole is another, even of the same size and time).
- get
- A content opened into
target(a new hidden file beside the one it will replace,share::temporary), and checked against its hash: whole and right, or nothing (targetremoved). Never more thanLARGESTbytes written, whatever the file says. Opened from the folder, else from the copy fetched from its server beside it (remote::overlay, brought byremote::fetch_wanted): a copy fetched that does not open whole is taken out there, and fetched again. - get_
from 🔒 - get_
unless 🔒 - As
get, the folder’s copy passed over as damaged whendamaged: found so before, and the same copy still (share::receive). - hash_
file - A file’s content hash (SHA-256) and size, read a piece at a time.
- hex 🔒
- keys 🔒
- The keys of sealed files, made from the records’ key for this format: one seals the pieces, one names the files.
- name
- A content’s name in the folder: made with a key, so that it tells nothing of the content to whoever lacks it (not even that two folders hold the same file).
- open_
into 🔒 - path
- present 🔒
- A sealed file there, opened; none when it is not, or only its empty placeholder (files kept on demand), which is not a damaged one.
- put
- A file sealed into the folder, unless its content is there already (from
any device).
hashis its content when gathered: read again here, a file that changed meanwhile is not sent, the next look sends it. The size sealed when written here; none when it was there. One there for long is made fresh: its writer does not take it out from under the record that names it again. - put_
again - A content sealed again over a copy in the folder that is damaged or cut (not of the size it was sealed at), or gone: the size sealed.
- seal_
into 🔒 - sweep
- The sealed files this device wrote that no record points to any more,
removed once that has lasted
UNUSED_DAYS.mineholds when a record last pointed to each (milliseconds),usedthe names records point to now, or named lately. One whose file was made fresh lately (sealed again, named again by another device) stays. - unseal 🔒
- A sealed file’s pieces, past its beginning, opened into
outand checked against the content’s hash:outgiven back once all of it opened whole and right. - write_
piece 🔒 - A piece sealed and written: its length (its top bit set for the end), its nonce, what is sealed.