Skip to content

Commit

Permalink
Handle missing repository_object during removal (#2478)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jan 30, 2022
1 parent 9bc550f commit 7bf62c4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,12 @@ async def common_update(self, ignore_issues=False, force=False) -> bool:
return False

# Update last updated
self.data.last_updated = self.repository_object.attributes.get("pushed_at", 0)
if self.repository_object:
self.data.last_updated = self.repository_object.attributes.get("pushed_at", 0)

# Update last available commit
await self.repository_object.set_last_commit()
self.data.last_commit = self.repository_object.last_commit
# Update last available commit
await self.repository_object.set_last_commit()
self.data.last_commit = self.repository_object.last_commit

# Get the content of hacs.json
if RepositoryFile.HACS_JSON in [x.filename for x in self.tree]:
Expand Down Expand Up @@ -909,6 +910,8 @@ def update_filenames(self) -> None:

async def get_tree(self, ref: str):
"""Return the repository tree."""
if self.repository_object is None:
raise HacsException("No repository_object")
try:
tree = await self.repository_object.get_tree(ref)
return tree
Expand All @@ -917,6 +920,8 @@ async def get_tree(self, ref: str):

async def get_releases(self, prerelease=False, returnlimit=5):
"""Return the repository releases."""
if self.repository_object is None:
raise HacsException("No repository_object")
try:
releases = await self.repository_object.get_releases(prerelease, returnlimit)
return releases
Expand Down Expand Up @@ -996,7 +1001,7 @@ async def common_update_data(self, ignore_issues: bool = False, force: bool = Fa
for treefile in self.tree:
self.treefiles.append(treefile.full_path)
except (AIOGitHubAPIException, HacsException) as exception:
if not self.hacs.status.startup:
if not self.hacs.status.startup and not ignore_issues:
self.logger.error("%s %s", self, exception)
if not ignore_issues:
raise HacsException(exception) from None
Expand Down

0 comments on commit 7bf62c4

Please sign in to comment.