Fox cloud: Fix stale cache settings - #4196
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a Fox cloud caching issue where persisted device_settings data could remain in an outdated “shape” across restarts, by introducing a cache version and forcing a one-time settings/scheduler refresh when the persisted version is stale.
Changes:
- Introduces
FOX_SETTINGS_CACHE_VERSIONand persistsdevice_settings_versionto detect and self-heal stale-shaped cached settings. - Updates
FoxAPI.run()to force a settings/scheduler refresh when the persisted cache version is behind, and persists the version once the scheduler refresh succeeds. - Adds regression tests covering stale-cache-version forced refresh behavior and correct version persistence semantics; bumps Predbat version to v8.44.4.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/predbat/fox.py | Adds settings cache versioning, persists version in cache, and forces a refresh when the cache version is stale. |
| apps/predbat/tests/test_fox_api.py | Adds tests for stale cache version forcing refresh and ensuring the version is only cleared after scheduler success. |
| apps/predbat/predbat.py | Bumps application version to v8.44.4. |
Comment on lines
+505
to
509
| if settings_updated or scheduler_updated: | ||
| # update_settings_from_schedule() (called from get_scheduler()) mutates | ||
| # device_settings too, so this must save on scheduler_updated as well - not | ||
| # just settings_updated - or a schedule-derived upgrade is lost on restart | ||
| await self._save_cache("device_settings", self.device_settings) |
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.
No description provided.