From f83fefaf84d52a7c1585da0430313720110aec41 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 15 Jan 2023 16:37:08 +0000 Subject: [PATCH] Unregister stale custom repositories during startup --- custom_components/hacs/base.py | 12 ++++++++++++ custom_components/hacs/repositories/base.py | 1 + 2 files changed, 13 insertions(+) diff --git a/custom_components/hacs/base.py b/custom_components/hacs/base.py index cbbc014e436..b39abb1ca3f 100644 --- a/custom_components/hacs/base.py +++ b/custom_components/hacs/base.py @@ -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: diff --git a/custom_components/hacs/repositories/base.py b/custom_components/hacs/repositories/base.py index e489b238e61..db9c961f3ee 100644 --- a/custom_components/hacs/repositories/base.py +++ b/custom_components/hacs/repositories/base.py @@ -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