Skip to content

Persist repository data after installing through the update entity#5383

Open
frenck wants to merge 1 commit into
mainfrom
frenck/persist-data-after-update-entity-install
Open

Persist repository data after installing through the update entity#5383
frenck wants to merge 1 commit into
mainfrom
frenck/persist-data-after-update-entity-install

Conversation

@frenck

@frenck frenck commented Jul 12, 2026

Copy link
Copy Markdown
Member

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.data to 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 in async_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

  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • The code change is tested and works locally.
  • Local tests pass.
  • There is no commented out code in this PR.

Copilot AI review requested due to automatic review settings July 12, 2026 19:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.install and asserts the stored version_installed is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants