diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..153f549 Binary files /dev/null and b/.DS_Store differ diff --git a/custom_components/.DS_Store b/custom_components/.DS_Store new file mode 100644 index 0000000..535d647 Binary files /dev/null and b/custom_components/.DS_Store differ diff --git a/custom_components/auto_backup/handlers.py b/custom_components/auto_backup/handlers.py index 456c16f..d67b066 100644 --- a/custom_components/auto_backup/handlers.py +++ b/custom_components/auto_backup/handlers.py @@ -1,3 +1,4 @@ +import aiofiles import asyncio import logging import shutil @@ -141,13 +142,13 @@ async def download_backup( if request.status not in (200, 400): _LOGGER.error("%s return code %d.", command, request.status) raise HassioAPIError() - - with open(destination, "wb") as file: + + async with aiofiles.open(destination, "wb") as file: while True: chunk = await request.content.read(CHUNK_SIZE) if not chunk: break - file.write(chunk) + await file.write(chunk) _LOGGER.info("Downloaded backup '%s' to '%s'", slug, destination) return