Use puffin_cache::digest in another site (#289)

This commit is contained in:
Charlie Marsh 2023-11-01 21:48:14 -07:00 committed by GitHub
parent 0c9e975f75
commit 2ee555df7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 11 deletions

2
Cargo.lock generated
View file

@ -2100,11 +2100,9 @@ name = "puffin-distribution"
version = "0.1.0"
dependencies = [
"anyhow",
"hex",
"pep440_rs 0.3.12",
"puffin-cache",
"puffin-package",
"sha2",
"url",
]

View file

@ -15,6 +15,4 @@ puffin-cache = { path = "../puffin-cache" }
puffin-package = { path = "../puffin-package" }
anyhow = { workspace = true }
hex = { workspace = true }
sha2 = { workspace = true }
url = { workspace = true }

View file

@ -3,7 +3,6 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use anyhow::{anyhow, Result};
use sha2::{Digest, Sha256};
use url::Url;
use pep440_rs::Version;
@ -358,12 +357,7 @@ impl<'a> RemoteDistributionRef<'a> {
Self::Registry(name, version, _) => {
format!("{}-{}", DistInfoName::from(*name), version)
}
Self::Url(_name, url) => {
let mut hasher = Sha256::new();
hasher.update(url.as_str().as_bytes());
let result = hasher.finalize();
hex::encode(result)
}
Self::Url(_name, url) => puffin_cache::digest(&CanonicalUrl::new(url)),
}
}
}