nardl: fix some warnings
This commit is contained in:
parent
afe1f86e1c
commit
279dea8167
|
@ -31,7 +31,7 @@ async fn main() -> eyre::Result<()> {
|
|||
|
||||
let cache_base_urls = SUBSTITUERS
|
||||
.iter()
|
||||
.map(|url| reqwest::Url::parse(*url))
|
||||
.map(|url| reqwest::Url::parse(url))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let output_path = Path::new(OUTPUT);
|
||||
|
@ -52,9 +52,9 @@ async fn main() -> eyre::Result<()> {
|
|||
let trusted_keys = KEYS
|
||||
.iter()
|
||||
.map(|key| -> eyre::Result<_> {
|
||||
let (name, public_str) = key.split_once(":").ok_or_eyre("Key has no name")?;
|
||||
let (name, public_str) = key.split_once(':').ok_or_eyre("Key has no name")?;
|
||||
let public_bytes = data_encoding::BASE64_NOPAD
|
||||
.decode(public_str.trim_end_matches("=").as_bytes())
|
||||
.decode(public_str.trim_end_matches('=').as_bytes())
|
||||
.wrap_err("Invalid base64 in key")?;
|
||||
Ok((
|
||||
name,
|
||||
|
@ -89,7 +89,7 @@ async fn main() -> eyre::Result<()> {
|
|||
|
||||
log::trace!("narinfo {}: {:?}", cache, parsed);
|
||||
|
||||
if &parsed.store_dir != store_dir.to_str().unwrap() {
|
||||
if parsed.store_dir != store_dir.to_str().unwrap() {
|
||||
eyre::bail!("Cache {} has a different store directory", cache);
|
||||
}
|
||||
}
|
||||
|
@ -107,12 +107,12 @@ async fn main() -> eyre::Result<()> {
|
|||
log::debug!("Requesting output {}", output);
|
||||
|
||||
let (fingerprint, _) = &output
|
||||
.split_once("-")
|
||||
.split_once('-')
|
||||
.ok_or_else(|| eyre::eyre!("Invalid output name {}", output))?;
|
||||
|
||||
// Parse, verify, and handle narinfo
|
||||
let (narinfo_text, cache_base_url) =
|
||||
get_narinfo(client.clone(), cache_base_urls.as_slice(), &fingerprint)
|
||||
get_narinfo(client.clone(), cache_base_urls.as_slice(), fingerprint)
|
||||
.await
|
||||
.wrap_err_with(|| format!("While processing {}", output))?;
|
||||
let narinfo_parsed = narinfo::NarInfo::parse(&narinfo_text).unwrap();
|
||||
|
@ -176,7 +176,7 @@ async fn main() -> eyre::Result<()> {
|
|||
let (hash_algorithm, hash_expected) = narinfo_parsed
|
||||
.nar_hash
|
||||
.as_ref()
|
||||
.split_once(":")
|
||||
.split_once(':')
|
||||
.ok_or_eyre("Invalid hash in nar")?;
|
||||
|
||||
if hash_algorithm != "sha256" {
|
||||
|
@ -197,7 +197,7 @@ async fn main() -> eyre::Result<()> {
|
|||
|
||||
let hash_found = hasher.finalize();
|
||||
|
||||
if &nix_base32::to_nix_base32(hash_found.as_ref()) != hash_expected {
|
||||
if nix_base32::to_nix_base32(hash_found.as_ref()) != hash_expected {
|
||||
eyre::bail!("Incorrect hash when downloading {}", output)
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,6 @@ async fn main() -> eyre::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
async fn get_narinfo<'a>(
|
||||
client: reqwest::Client,
|
||||
cache_base_urls: &'a [reqwest::Url],
|
||||
|
@ -282,7 +281,7 @@ fn verify_signature(
|
|||
);
|
||||
log::trace!("narinfo fingerprint: `{}`", fingerprint);
|
||||
|
||||
key.verify_strict(&fingerprint.as_bytes(), &signature)
|
||||
key.verify_strict(fingerprint.as_bytes(), &signature)
|
||||
.wrap_err("Invalid signature")?;
|
||||
return Ok(());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue