Fix root crate compilation dependencies to force sha1*

This commit is contained in:
Igor Katson 2024-08-28 13:32:42 +01:00
parent 9eed5aeb07
commit 0214817122
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
7 changed files with 47 additions and 3 deletions

View file

@ -9,3 +9,8 @@ pub mod speed_estimator;
pub mod torrent_metainfo;
pub use hash_id::Id20;
assert_cfg::exactly_one! {
feature = "sha1-crypto-hash",
feature = "sha1-ring",
}

View file

@ -29,7 +29,11 @@ pub fn torrent_from_bytes_ext<'de, BufType: Deserialize<'de> + From<&'de [u8]>>(
let mut t = TorrentMetaV1::deserialize(&mut de)?;
let (digest, info_bytes) = match (de.torrent_info_digest, de.torrent_info_bytes) {
(Some(digest), Some(info_bytes)) => (digest, info_bytes),
_ => anyhow::bail!("programming error"),
(o1, o2) => anyhow::bail!(
"programming error: digest.is_some()={}, info_bytes.is_some()={}. Probably one of bencode/sha1* features isn't enabled.",
o1.is_some(),
o2.is_some()
),
};
t.info_hash = Id20::new(digest);
Ok(ParsedTorrent {