outposts: replace migration with string backup handler

This commit is contained in:
Jens Langhammer
2020-10-19 16:04:38 +02:00
parent 597188c7ee
commit 7203bd37a3
2 changed files with 5 additions and 32 deletions

View File

@ -204,7 +204,11 @@ class OutpostState:
def for_channel(outpost: Outpost, channel: str) -> "OutpostState":
"""Get state for a single channel"""
key = f"{outpost.state_cache_prefix}_{channel}"
data = cache.get(key, {"uid": channel})
default_data = {"uid": channel}
data = cache.get(key, default_data)
if isinstance(data, str):
cache.delete(key)
data = default_data
state = from_dict(OutpostState, data)
state.uid = channel
# pylint: disable=protected-access