Skip to content

Commit

Permalink
Rewrites "original_name" method to check if "cls" has a "backmap"
Browse files Browse the repository at this point in the history
In some cases, such as fail of "mock --chain --recurse some.src.rpm.tofail",
FileDownloader "cls" may not have a "backmap" attribute. So we have to check
if it exists before accessing it.

Fixes: rpm-software-management#1345
  • Loading branch information
nikitych authored and praiskup committed Mar 11, 2024
1 parent 93acba9 commit 71a8580
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mock/py/mockbuild/file_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def _get_inner(cls, url):
@classmethod
def original_name(cls, localname):
""" Get the URL from the local name """
if not cls.backmap:
return localname
return cls.backmap.get(localname, localname)
if getattr(cls, 'backmap', None):
return cls.backmap.get(localname, localname)
return localname

@classmethod
def cleanup(cls):
Expand Down
5 changes: 5 additions & 0 deletions releng/release-notes-next/FileDownloader-original_name.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
When a `mock --chain --recurse` fails to built at least one package, it is
unable to print a list of failed packages and displays `AttributeError: type
object 'FileDownloader' has no attribute 'backmap'` instead. The `original_name`
method of `FileDownloader` class has been fixed, and the chain build results
displayed as expected ([issue#1345][]).

0 comments on commit 71a8580

Please sign in to comment.