From c53ee28adee3879aec5d48ad11e3a798af100e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 15 Jan 2023 17:40:43 +0100 Subject: [PATCH] Unregister stale custom repositories during startup (#3012) --- 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