1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-07 13:52:20 +01:00

[micro_wake_word] Remove duplicated download code (#7401)

This commit is contained in:
Jesse Hills
2024-09-05 12:49:01 +12:00
committed by GitHub
parent 71a7f6383f
commit dc4e60526c
2 changed files with 7 additions and 28 deletions

View File

@@ -80,10 +80,10 @@ def compute_local_file_dir(domain: str) -> Path:
return base_directory
def download_content(url: str, path: Path, timeout=NETWORK_TIMEOUT) -> None:
def download_content(url: str, path: Path, timeout=NETWORK_TIMEOUT) -> bytes:
if not has_remote_file_changed(url, path):
_LOGGER.debug("Remote file has not changed %s", url)
return
return path.read_bytes()
_LOGGER.debug(
"Remote file has changed, downloading from %s to %s",
@@ -102,4 +102,6 @@ def download_content(url: str, path: Path, timeout=NETWORK_TIMEOUT) -> None:
raise cv.Invalid(f"Could not download from {url}: {e}")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(req.content)
data = req.content
path.write_bytes(data)
return data