crates/veilvoice-verify/src/discover.rs
veilvoice-verify · 460 lines · read the source here · or on GitHub
Finding a release to check, without being told where it is.
Why this exists
Verifying a download used to require naming three files and knowing a tag. That is fine for somebody who has already read the instructions and is wrong for everybody else, and "everybody else" is precisely the population a verifier exists to serve. Somebody who has just downloaded an archive and wants to know whether it is the real one should be able to run this and be told.
So: look in the obvious places, in an obvious order, and say what was found. Nothing here downloads, nothing here guesses at a hash, and nothing here reports "verified" on the strength of a filename.
Where it looks, and why in that order
- The directory given, if one was.
- The current working directory, where somebody who has just
cd-ed to their downloads will be. - The directory the running binary is in, where somebody who unpacked the archive and double-clicked the verifier inside it will be.
- The usual download directories for the platform.
Each is searched one level deep only. A recursive walk of a home directory is slow, surprising, and would let a verifier wander into places nobody asked it to look at.
What counts as a release archive
A file whose name starts veilvoice- and ends in one of the archive extensions this project publishes. That is a filename test and it proves nothing at all: it is how candidates are found, never how they are judged. Every candidate still has to survive the signature and the hash, and a file that merely looks the part fails exactly as loudly as one that does not.
In plain words
Looks for a downloaded release to check, so you can double-click the verifier and have it work.
It looks in the folder it is in, the current folder, one level up from each of those, and your Downloads and Desktop. If it finds nothing it says exactly where it looked, rather than reporting a failure that leaves you guessing.
WHAT THIS FILE CONTAINS
460 lines defining 7 functions (7 public), 1 type and 4 constants. Everything below is read out of the source, so it cannot disagree with the code.
The types it owns.
struct Foundline 65 · What was found in one directory.
What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.
Found::is_completeline 80 · Whether this directory holds everything needed to verify offline.Found::is_emptyline 85 · Whether anything at all turned up.Found::missingline 90 · What is missing, in words, for a message to the user.searchline 223 · Look everywhere worth looking and return the first directory that holds a complete, checkable set, or, failing that, everything that turned up.
reacheslook_in,places,looks_like_archive
WHAT CALLS WHAT
The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.
The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
n_is_complete(["Found::is_complete<br/>line 80"])
n_is_empty(["Found::is_empty<br/>line 85"])
n_missing(["Found::missing<br/>line 90"])
n_looks_like_archive["looks_like_archive<br/>line 108"]
n_look_in["look_in<br/>line 114"]
n_places["places<br/>line 150"]
n_search(["search<br/>line 223"])
n_look_in --> n_looks_like_archive
n_search --> n_look_in
n_search --> n_places
click n_is_complete href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L80" "open the source"
click n_is_empty href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L85" "open the source"
click n_missing href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L90" "open the source"
click n_looks_like_archive href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L108" "open the source"
click n_look_in href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L114" "open the source"
click n_places href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L150" "open the source"
click n_search href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/src/discover.rs#L223" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_is_complete,n_is_empty,n_missing,n_search entry
classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
class n_looks_like_archive,n_look_in,n_places api
This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.
ITEMS
| Item | Line | Documentation |
|---|---|---|
ARCHIVES const | 50 | The extensions this project publishes releases as. |
SUMS pub const | 53 | The names of the two files a signed release carries beside its archives. |
SUMS_SIG pub const | 55 | The detached signature over SUMS. |
CONTENTS pub const | 61 | The list of what is inside each archive, itself covered by SUMS. |
Found pub struct | 65 | What was found in one directory. |
Found::is_complete pub fn | 80 | Whether this directory holds everything needed to verify offline. |
Found::is_empty pub fn | 85 | Whether anything at all turned up. |
Found::missing pub fn | 90 | What is missing, in words, for a message to the user. |
looks_like_archive pub fn | 108 | Whether a filename looks like one of this project's release archives. |
look_in pub fn | 114 | Look in one directory, one level deep. |
places pub fn | 150 | Every place worth looking, in order, without duplicates. |
search pub fn | 223 | Look everywhere worth looking and return the first directory that holds a complete, checkable set, or, failing that, everything that turned up. |