Persist repository data after installing through the update entity#5383
Open
frenck wants to merge 1 commit into
Open
Persist repository data after installing through the update entity#5383frenck wants to merge 1 commit into
frenck wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a persistence gap in the update-entity install path so that repository installation state (notably installed_version) is written to .storage/hacs.data immediately after a successful update.install, matching the websocket download behavior and preventing state regressions after an unexpected restart.
Changes:
- Persist HACS repository data to storage after a successful install initiated via the update entity (
async_install). - Add a regression test that installs via
update.installand asserts the storedversion_installedis updated. - Add an API-usage snapshot for the new test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
custom_components/hacs/update.py |
Writes HACS data to storage after successful update-entity installs to prevent losing the new installed version on restart. |
tests/repositories/test_update_repository.py |
Adds a regression test verifying update.install updates persisted storage state. |
tests/snapshots/api-usage/tests/repositories/test_update_repositorytest-update-repository-entity-persists-installed-version.json |
Captures expected outbound request usage for the new test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
The websocket download path writes the repository data to storage after a download, but the update entity path does not. After installing an update through the update entity (including automations calling
update.install), the new installed version only lived in memory.A Home Assistant crash or power loss before the next incidental write reverted
.storage/hacs.datato the old state: on restart HACS reported an update pending for something already on disk, and a pinned version was forgotten.This adds a
hacs.data.async_write()after a successful install inasync_install, mirroring what the websocket download handler already does.The added test installs a new version through the update entity and asserts the stored data reflects it. It fails on the previous code.
Type of change
Checklist