From ded428f788ff5f5dc0c0609238e8058d0d54a096 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Thu, 7 Nov 2024 21:32:14 -0500 Subject: [PATCH] Enable syncing without filelists present closes #3777 --- CHANGES/3777.bugfix | 1 + pulp_rpm/app/tasks/synchronizing.py | 22 ++++++++++++++-------- requirements.txt | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 CHANGES/3777.bugfix diff --git a/CHANGES/3777.bugfix b/CHANGES/3777.bugfix new file mode 100644 index 000000000..d94e592d2 --- /dev/null +++ b/CHANGES/3777.bugfix @@ -0,0 +1 @@ +Make it possible to sync repositories without filelists.xml or other.xml metadata \ No newline at end of file diff --git a/pulp_rpm/app/tasks/synchronizing.py b/pulp_rpm/app/tasks/synchronizing.py index d62d06717..82d4bf39a 100644 --- a/pulp_rpm/app/tasks/synchronizing.py +++ b/pulp_rpm/app/tasks/synchronizing.py @@ -901,13 +901,17 @@ async def parse_distribution_tree(self): async def parse_repository_metadata(self, repomd, metadata_results): """Parse repository metadata.""" - needed_metadata = set(PACKAGE_REPODATA) - set(metadata_results.keys()) - - if needed_metadata: + if "primary" not in metadata_results.keys(): raise FileNotFoundError( - _("XML file(s): {filenames} not found").format(filenames=", ".join(needed_metadata)) + "Repository doesn't contain required metadata file 'primary.xml'" ) + if "filelists" not in metadata_results.keys(): + log.warn("Repository doesn't contain metadata file 'filelists.xml'") + + if "other" not in metadata_results.keys(): + log.warn("Repository doesn't contain metadata file 'other.xml'") + await self.parse_distribution_tree() # modularity-parsing MUST COME BEFORE package-parsing! @@ -927,9 +931,9 @@ async def parse_repository_metadata(self, repomd, metadata_results): # **Now** we can successfully parse package-metadata await self.parse_packages( - metadata_results["primary"], - metadata_results["filelists"], - metadata_results["other"], + metadata_results.get("primary"), + metadata_results.get("filelists"), + metadata_results.get("other"), modulemd_list=modulemd_list, ) @@ -1168,7 +1172,9 @@ async def parse_packages_components(self, comps_result): async def parse_packages(self, primary_xml, filelists_xml, other_xml, modulemd_list=None): """Parse packages from the remote repository.""" parser = cr.RepositoryReader.from_metadata_files( - primary_xml.path, filelists_xml.path, other_xml.path + primary_xml.path, + filelists_xml.path if filelists_xml else None, + other_xml.path if other_xml else None, ) # skip SRPM if defined diff --git a/requirements.txt b/requirements.txt index 22e49f0fe..1509821e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -createrepo_c~=1.1.2 +createrepo_c~=1.2 django_readonly_field~=1.1.1 jsonschema>=4.6,<5.0 libcomps>=0.1.20.post1,<0.2