Skip to main content

advertised_nar_url

Function advertised_nar_url 

Source
pub fn advertised_nar_url(narinfo: &str) -> Option<String>
Expand description

The NAR path a stored narinfo advertises, if it advertises an addressable one.

None covers both “no URL: line here” and “its URL: is not addressable”. Both mean the same thing to a caller: there is no NAR here we are entitled to key, index, or delete.

§Why this reads the one field instead of calling NarInfo::parse

NarInfo::parse requires FileHash and FileSize, and rejects the whole document when either is absent. A narinfo missing them still advertises a NAR — a client will still fetch that URL: and still hard-fail on a 404 — so indexing through the full parse would leave exactly those narinfos out of the index. That is not a harmless gap: an unindexed narinfo sharing a narhash with an indexed one gets stranded the moment the indexed one is deleted. The reverse index must see every narinfo that names a NAR, whatever else is wrong with it, so it reads the field that matters and judges nothing else.