Skip to content

Commit

Permalink
Fixed parsing versions file with missing checksum
Browse files Browse the repository at this point in the history
At some point in time, rubygems.org was shipping a versions file where
the md5 checksum is missing on one line. We will just ignore this and
sync the content anyway.

fixes #313
  • Loading branch information
mdellweg committed Sep 18, 2024
1 parent 0e26732 commit 0e84636
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/313.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed handling somewhat inconsistent metadata on rubygems.org where an md5 checksum is missing in the versions file.
3 changes: 3 additions & 0 deletions pulp_gem/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ async def run(self):
info_url = urljoin(urljoin(self.remote.url, "info/"), name)
if "md5" in settings.ALLOWED_CONTENT_CHECKSUMS:
extra_kwargs = {"expected_digests": {"md5": md5_sum}}
elif md5_sum is None:
extra_kwargs = {}
log.warn(f"Checksum of info file for '{name}' was not provided.")
else:
extra_kwargs = {}
log.warn(f"Checksum of info file for '{name}' could not be validated.")
Expand Down
6 changes: 5 additions & 1 deletion pulp_gem/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ async def read_versions(relative_path):
continue
if preamble:
continue
name, versions_str, md5_sum = line.split(" ", maxsplit=2)
# Dirty trick to make the md5sum default to None
split_line = line.split(" ", maxsplit=2) + [None]
name = split_line[0]
versions_str = split_line[1]
md5_sum = split_line[2]
ext_versions = versions_str.split(",")
entry = results.get(name) or ([], "")
results[name] = (entry[0] + ext_versions, md5_sum)
Expand Down

0 comments on commit 0e84636

Please sign in to comment.