Skip to main content

Module files

Module files 

Source
Expand description

File transfer: chunking, reassembly, hash verification, cache, save.

Cache layout: <data_dir>/files/cache/<file_id> // verified, complete <data_dir>/files/cache/<file_id>.part // in-progress reassembly

File-IDs are the SHA-256 hash of the wire bytes (plaintext for non-encrypted offers, ciphertext for encrypted offers — the encryption layer is a separate concern). Receivers verify each completed transfer’s bytes match the announced file_id before exposing the file to the caller.

Modules§

encryption
File encryption for room attachments.

Structs§

CompletedFile
What accept_chunk returns on the chunk that completes the transfer.
FileManager
OutgoingPlan
What prepare_outgoing hands back: enough to drive a sequence of FileOffer + N FileChunk gossipsub messages.

Constants§

CHUNK_SIZE
Bytes per chunk on the wire. Picked to fit comfortably under gossipsub’s per-message budget even after base64 expansion (64 KiB raw → ~88 KiB base64).
MAX_FILE_SIZE
Hard cap on a single offer for Phase 2. Larger files defer to a dedicated libp2p stream protocol (see plan.md Phase 3 notes).

Functions§

guess_mime
Best-effort MIME guess from a filename. Returns None for unknown extensions — receivers should not depend on this being present.