From a25b4c7b7f8a527ffd878140526be53ba9c79b0e Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Tue, 17 Sep 2024 17:45:23 +0200 Subject: [PATCH] Fixed parsing versions file with missing checksum 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 --- CHANGES/313.bugfix | 1 + pulp_gem/app/tasks/synchronizing.py | 3 +++ pulp_gem/specs.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 CHANGES/313.bugfix diff --git a/CHANGES/313.bugfix b/CHANGES/313.bugfix new file mode 100644 index 00000000..4bcccd76 --- /dev/null +++ b/CHANGES/313.bugfix @@ -0,0 +1 @@ +Fixed handling somewhat inconsistent metadata on rubygems.org where an md5 checksum is missing in the versions file. diff --git a/pulp_gem/app/tasks/synchronizing.py b/pulp_gem/app/tasks/synchronizing.py index f945c39a..0968646e 100644 --- a/pulp_gem/app/tasks/synchronizing.py +++ b/pulp_gem/app/tasks/synchronizing.py @@ -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.") diff --git a/pulp_gem/specs.py b/pulp_gem/specs.py index d0d9cd7e..c7384966 100644 --- a/pulp_gem/specs.py +++ b/pulp_gem/specs.py @@ -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)