mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Store: copy pending data (#59934)
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
from contextlib import suppress
|
||||
from copy import deepcopy
|
||||
import inspect
|
||||
from json import JSONEncoder
|
||||
import logging
|
||||
@@ -133,6 +134,10 @@ class Store:
|
||||
# If we didn't generate data yet, do it now.
|
||||
if "data_func" in data:
|
||||
data["data"] = data.pop("data_func")()
|
||||
|
||||
# We make a copy because code might assume it's safe to mutate loaded data
|
||||
# and we don't want that to mess with what we're trying to store.
|
||||
data = deepcopy(data)
|
||||
else:
|
||||
data = await self.hass.async_add_executor_job(
|
||||
json_util.load_json, self.path
|
||||
|
||||
Reference in New Issue
Block a user