Make hashes optional (#910)

There is no guarantee that indexes provide hashes at all or the sha256
we support specifically. [PEP
503](https://peps.python.org/pep-0503/#specification):

> The URL SHOULD include a hash in the form of a URL fragment with the
following syntax: #<hashname>=<hashvalue>, where <hashname> is the
lowercase name of the hash function (such as sha256) and <hashvalue> is
the hex encoded digest.

We instead use the url as input to generate a hash when caching.
This commit is contained in:
konsti 2024-01-14 22:32:55 +01:00 committed by GitHub
parent 9ad19b7e54
commit 5ffbfadf66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 104 additions and 41 deletions

View file

@ -270,8 +270,10 @@ impl std::fmt::Display for DisplayResolutionGraph<'_> {
.filter(|hashes| !hashes.is_empty())
{
for hash in hashes {
writeln!(f, " \\")?;
write!(f, " --hash={hash}")?;
if let Some(hash) = hash.to_string() {
writeln!(f, " \\")?;
write!(f, " --hash={hash}")?;
}
}
}
}