Skip to content

Commit

Permalink
more info on a size parse failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3 committed Oct 7, 2024
1 parent 3020bf1 commit 4d3ca4e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/trust/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,24 @@ pub fn trust_record(s: &str) -> Result<Trust, Error> {
match v.as_slice() {
[f, sz, sha] => Ok(Trust {
path: f.trim().to_string(),
size: sz.trim().parse()?,
size: sz
.trim()
.parse()
.map_err(|e| MalformattedTrustEntry(format!("size parse {e} [{s}]")))?,
hash: sha.trim().to_string(),
}),
_ => Err(MalformattedTrustEntry(s.to_string())),
}
}

/// Parse a trust record with type metadata data
/// Formatted as four space separated values
/// TYPE PATH SIZE HASH
/// The TYPE can be system or ancillary
/// 0 - unknown
/// 1 - RPM
/// 2 - File
/// 3 - Debian
pub(crate) fn strtyped_trust_record(s: &str, t: &str) -> Result<(Trust, TrustSource), Error> {
match t {
"1" => trust_record(s).map(|t| (t, System)),
Expand Down

0 comments on commit 4d3ca4e

Please sign in to comment.