Skip to content

Commit

Permalink
Enable syncing without filelists present
Browse files Browse the repository at this point in the history
closes #3777
  • Loading branch information
dralley committed Nov 12, 2024
1 parent 5d81100 commit de9a067
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES/3777.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make it possible to sync repositories without filelists.xml or other.xml metadata
22 changes: 14 additions & 8 deletions pulp_rpm/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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,
)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit de9a067

Please sign in to comment.