Fix a bug where solar conditions and status data were not properly persisted to disk between restarts. Release v2.0.5

This commit is contained in:
Ian Renton
2026-08-29 09:17:24 +01:00
parent 8451ca2727
commit ba56acd7ac
18 changed files with 89 additions and 56 deletions
+10 -19
View File
@@ -6,6 +6,7 @@ import diskcache
from core.config import MAX_ALERT_AGE, MAX_SPOT_AGE
from core.live_data_cache import LiveDataCache
from core.single_object_data_cache import SingleObjectDataCache
from data.solar_conditions import SolarConditions
logger = logging.getLogger(__name__)
@@ -34,10 +35,8 @@ class DataStore:
self.dxcc_data = None
self.dxcc_lookup_by_call_regex = []
self.sigrefs = None
self.status_data = {}
self._status = None
self.solar_conditions = {}
self._solar = None
self.status = None
self.solar_conditions = None
# ITU/CQ zone GeoJSON data is only ever loaded statically from a local file so these don't even need to be
# caches, they can just be straight objects
self.cq_zone_data = None
@@ -46,16 +45,11 @@ class DataStore:
def setup(self):
Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
# Standard disk cache for solar data and status data, but each cache contains only a single object which we
# expose to the wider application
self._solar = diskcache.Cache(f"{CACHE_DIR}solar")
if "solar_conditions" not in self._solar:
self._solar.add("solar_conditions", SolarConditions())
self.solar_conditions = self._solar.get("solar_conditions")
self._status = diskcache.Cache(f"{CACHE_DIR}status")
if "status_data" not in self._status:
self._status.add("status_data", {})
self.status_data = self._status.get("status_data")
# For solar data and status data, we use a wrapper around disk cache where each cache contains only a single
# object exposed to the wider application, and provides a store() method for callers to notify diskcache that
# the object has changed and needs to be re-cached.
self.solar_conditions = SingleObjectDataCache(f"{CACHE_DIR}solar", SolarConditions())
self.status = SingleObjectDataCache(f"{CACHE_DIR}status", {})
# Standard disk cache for static reference and SIG ref data. Separate provider threads will repopulate these on
# a regular basis but there's no need for a TTL since old data is better than no data.
@@ -116,13 +110,10 @@ class DataStore:
self.dxcc_lookup_by_call_regex.append((re.compile(entry["prefixRegex"]), entry["entityCode"]))
def close(self):
self.spots.save_snapshot()
self.alerts.save_snapshot()
self.spots.close()
self.alerts.close()
self._solar.close()
self._status.close()
self.solar.close()
self.status.close()
self.dxcc_data.close()
self.sigrefs.close()
self.callsign_data_countryfiles.close()