Skip to content

Commit

Permalink
handle deprecation of link.metadata_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Feb 5, 2024
1 parent 0cc848e commit 25844c5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/poetry/repositories/http_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,18 @@ def _get_info_from_metadata(self, link: Link) -> PackageInfo | None:
assert link.metadata_url is not None
response = self.session.get(link.metadata_url)
distribution = pkginfo.Distribution()
if link.metadata_hash_name is not None:
metadata_hash = getattr(hashlib, link.metadata_hash_name)(
if link.metadata_hashes and (
hash_name := get_highest_priority_hash_type(
set(link.metadata_hashes.keys()), f"{link.filename}.metadata"
)
):
metadata_hash = getattr(hashlib, hash_name)(
response.text.encode()
).hexdigest()

if metadata_hash != link.metadata_hash:
if metadata_hash != link.metadata_hashes[hash_name]:
self._log(
f"Metadata file hash ({metadata_hash}) does not match"
f" expected hash ({link.metadata_hash})."
f" expected hash ({link.metadata_hashes[hash_name]})."
f" Metadata file for {link.filename} will be ignored.",
level="warning",
)
Expand Down

0 comments on commit 25844c5

Please sign in to comment.