Skip to content

Commit f097992

Browse files
committed
fix: improve partial update code.
1 parent a53a89a commit f097992

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

roborock/devices/traits/v1/home.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,18 @@ async def _update_current_map(
249249
if update_cache:
250250
cache_data = await self._cache.get()
251251
cache_data.home_map_info[map_flag] = map_info
252+
# Migrate existing cached content to base64 if needed
253+
if cache_data.home_map_content and not cache_data.home_map_content_base64:
254+
cache_data.home_map_content_base64 = {
255+
k: base64.b64encode(v).decode("utf-8") for k, v in cache_data.home_map_content.items()
256+
}
257+
cache_data.home_map_content = {}
252258
if map_content.raw_api_response:
253259
if cache_data.home_map_content_base64 is None:
254260
cache_data.home_map_content_base64 = {}
255-
cache_data.home_map_content_base64[map_flag] = base64.b64encode(
256-
map_content.raw_api_response
257-
).decode("utf-8")
258-
if cache_data.home_map_content and map_flag in cache_data.home_map_content:
259-
del cache_data.home_map_content[map_flag]
261+
cache_data.home_map_content_base64[map_flag] = base64.b64encode(map_content.raw_api_response).decode(
262+
"utf-8"
263+
)
260264
await self._cache.set(cache_data)
261265

262266
if self._home_map_info is None:

0 commit comments

Comments
 (0)