Repository navigation
Conversation
The HA Update entity flow (`update.async_install` → `repository.async_download_repository` → `_async_post_install`) never called `async_write`, so updates only landed on disk when the next unrelated websocket action fired or when `EVENT_HOMEASSISTANT_FINAL_WRITE` ran at shutdown. On Docker installs the container is often killed without a graceful stop and the event never fires, so HACS forgets it had updated the repository. Schedule a debounced write at the end of `_async_post_install` via `Store.async_delay_save` so every install path persists, while bursts (bulk updates, queued installs) coalesce into a single disk write per store. HA's Store also flushes pending delayed saves on shutdown for free, so the existing `EVENT_HOMEASSISTANT_FINAL_WRITE` safety net stays as belt-and-braces. Refactor `HacsData` to use pure sync builders for the three store payloads (`hacs`, `data`, `repositories`) so both the eager `async_write` path and the new `async_schedule_write` path share the same assembly logic without relying on a mutable `self.content` side-effect.
There was a problem hiding this comment.
Pull request overview
Refactors HACS data persistence to support debounced writes via a new async_delay_save_to_store() helper and a HacsData.async_schedule_write() method, with data-building logic extracted into pure _build_* callbacks. Repository post-install now triggers a scheduled write instead of relying on the caller to flush immediately.
Changes:
- Add
async_delay_save_to_store()wrapper aroundStore.async_delay_saveinutils/store.py. - Split
HacsDatawrite path into pure_build_hacs_data/_build_repositories_data/_build_experimental_dataand rename per-repo helpers to_repository_export/_experimental_repository_export; addasync_schedule_write(). - Call
self.hacs.data.async_schedule_write()at the end of_async_post_install.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| custom_components/hacs/utils/store.py | New async_delay_save_to_store helper that delegates to Store.async_delay_save on a store fetched via get_store_for_key. |
| custom_components/hacs/utils/data.py | Refactors data export to pure builders and introduces async_schedule_write using the new delayed-save helper. |
| custom_components/hacs/repositories/base.py | Schedules a debounced data write after post-install steps complete. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for this. Marketplace already encodes off the event loop and batches its writes, so a debounce adds little there, and it would delay storing an install. HACS development continues in core (see #5590), closing this here. ../Frenck Blogging my personal ramblings at frenck.dev |
No description provided.