#743 - Trying to fix this.

This commit is contained in:
ccostan
2020-05-21 18:48:00 -04:00
parent cf3764e3e4
commit 5c7334bc05
42 changed files with 863 additions and 513 deletions

View File

@@ -6,7 +6,8 @@ from .hacsbase.const import STORAGE_VERSION
async def async_load_from_store(hass, key):
"""Load the retained data from store and return de-serialized data."""
store = Store(hass, STORAGE_VERSION, f"hacs.{key}", encoder=JSONEncoder)
key = key if "/" in key else f"hacs.{key}"
store = Store(hass, STORAGE_VERSION, key, encoder=JSONEncoder)
restored = await store.async_load()
if restored is None:
return {}
@@ -15,5 +16,14 @@ async def async_load_from_store(hass, key):
async def async_save_to_store(hass, key, data):
"""Generate dynamic data to store and save it to the filesystem."""
store = Store(hass, STORAGE_VERSION, f"hacs.{key}", encoder=JSONEncoder)
key = key if "/" in key else f"hacs.{key}"
store = Store(hass, STORAGE_VERSION, key, encoder=JSONEncoder)
await store.async_save(data)
async def async_remove_store(hass, key):
"""Remove a store element that should no longer be used"""
if "/" not in key:
return
store = Store(hass, STORAGE_VERSION, key, encoder=JSONEncoder)
await store.async_remove()