Support MD5 hashes (#1556)

## Summary

We can add other hashes if necessary, but I don't know that they're
really used in practice.

Closes https://github.com/astral-sh/uv/issues/1547.
This commit is contained in:
Charlie Marsh 2024-02-16 19:25:16 -05:00 committed by GitHub
parent 9e0336c28a
commit c1eb6130e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 95 additions and 15 deletions

View file

@ -678,7 +678,7 @@ impl Identifier for Url {
impl Identifier for File {
fn distribution_id(&self) -> DistributionId {
if let Some(hash) = &self.hashes.sha256 {
if let Some(hash) = self.hashes.as_str() {
DistributionId::new(hash)
} else {
self.url.distribution_id()
@ -686,7 +686,7 @@ impl Identifier for File {
}
fn resource_id(&self) -> ResourceId {
if let Some(hash) = &self.hashes.sha256 {
if let Some(hash) = self.hashes.as_str() {
ResourceId::new(hash)
} else {
self.url.resource_id()