diff --git a/CHANGELOG.md b/CHANGELOG.md index f28cd17..4bd0e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [1.2.6] - 2026-03-18 + +### Fixed +- **Blocking `open()` call inside the event loop:** replaced the synchronous `open(tmp_path, "wb")` used during chunk-writing with `aiofiles.open()` so that file I/O is no longer performed on the event-loop thread. This resolves the `homeassistant.util.loop` warning *"Detected blocking call to open … inside the event loop"*. `aiofiles>=23.1.0` has been added as a runtime requirement. + +--- + ## [1.2.5] - 2026-03-11 ### Changed @@ -236,6 +243,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Service `media_downloader.download_file` with optional subdirectories, custom filenames, overwrite control, and per-download timeout. - Events: `media_downloader_download_started`, `media_downloader_download_completed` (with `success` and `error` fields). +[1.2.6]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.5...v1.2.6 [1.2.5]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.4...v1.2.5 [1.2.4]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.3...v1.2.4 [1.2.3]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.2...v1.2.3 diff --git a/custom_components/advanced_downloader/__init__.py b/custom_components/advanced_downloader/__init__.py index 78d14d7..7bb597c 100644 --- a/custom_components/advanced_downloader/__init__.py +++ b/custom_components/advanced_downloader/__init__.py @@ -4,6 +4,7 @@ import os import sys +import aiofiles import aiohttp import logging from pathlib import Path @@ -186,10 +187,10 @@ async def _async_download(call: ServiceCall) -> None: async with session.get(url) as resp: if resp.status != 200: raise HomeAssistantError(f"HTTP error {resp.status}: {url}") - with open(tmp_path, "wb") as f: + async with aiofiles.open(tmp_path, "wb") as f: async for chunk in resp.content.iter_chunked(1024 * 64): if chunk: - f.write(chunk) + await f.write(chunk) if dest_path.exists() and not do_overwrite: raise HomeAssistantError(f"File exists and overwrite is False: {dest_path}") diff --git a/custom_components/advanced_downloader/manifest.json b/custom_components/advanced_downloader/manifest.json index 1d9db59..a713a33 100644 --- a/custom_components/advanced_downloader/manifest.json +++ b/custom_components/advanced_downloader/manifest.json @@ -8,6 +8,6 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/Geek-MD/Advanced_Downloader/issues", "quality_scale": "legacy", - "requirements": [], - "version": "1.2.5" + "requirements": ["aiofiles>=23.1.0"], + "version": "1.2.6" } diff --git a/requirements.txt b/requirements.txt index 5272d71..9e6b192 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ mypy==1.10.0 ruff==0.14.3 pytest==8.3.2 voluptuous==0.15.2 +types-aiofiles>=23.1.0