Skip to main content

read

Function read 

Source
pub fn read(
    cwd: &Path,
    document_roots: &[PathBuf],
    path: &str,
    reviewable: bool,
    ceiling_bytes: u64,
) -> Result<DocumentRead, DocumentRefusal>
Expand description

Read one document out of cwd’s tree, or under one of document_roots.

path resolves against cwd. The read answers whether the DOCUMENT is reviewable - the commentable set the hand-off has always offered, by extension, while a PDF and a binary open read-only - so a viewer’s door does not depend on how the page was reached. The Files reader’s wider UTF-8 drawing classification is the CLIENT’s policy, not this read’s: the wire keeps the hand-off’s extension kind, so the hand-off viewer and its documented behaviour are unchanged. The request’s reviewable flag asks the hand-off’s own question and is refused for a PDF, whose kind can never carry a review. The read is bounded by ceiling_bytes, and a refusal names its reason.

document_roots are the extra roots the project allows - the document_roots entries of its forge.toml project. Each is canonicalized before the comparison, like the requested path, so a root behind a symlink is judged by where it really points; a root that cannot be canonicalized is compared lexically, which refuses nothing a resolvable path would have been allowed under.