Skip to content

Commit

Permalink
Unregister stale custom repositories during startup (#3012)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jan 15, 2023
1 parent 7e030dd commit c53ee28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,18 @@ async def async_get_category_repositories_experimental(self, category: str) -> N
if category == "integration":
self.status.inital_fetch_done = True

if self.stage == HacsStage.STARTUP:
for repository in self.repositories.list_all:
if (
repository.data.category == category
and not repository.data.installed
and not self.repositories.is_default(repository.data.id)
):
repository.logger.debug(
"%s Unregister stale custom repository", repository.string
)
self.repositories.unregister(repository)

async def async_get_category_repositories(self, category: HacsCategory) -> None:
"""Get repositories from category."""
if self.system.disabled:
Expand Down
1 change: 1 addition & 0 deletions custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ async def common_registration(self) -> None:

if self.repository_object:
self.data.last_updated = self.repository_object.attributes.get("pushed_at", 0)
self.data.last_fetched = datetime.utcnow()

# Set topics
self.data.topics = self.data.topics
Expand Down

0 comments on commit c53ee28

Please sign in to comment.