Handle stream failures in recorder (#47151)

* Handle stream failures in recorder

Fail gracefully with an error message when the recorder is invoked with no segments due to a stream failure.

* Update homeassistant/components/stream/recorder.py

Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>

Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>
This commit is contained in:
Allen Porter 2021-02-28 18:01:28 -08:00 committed by GitHub
parent 44ed6cda40
commit 715a254913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -21,6 +21,11 @@ def async_setup_recorder(hass):
def recorder_save_worker(file_out: str, segments: Deque[Segment]):
"""Handle saving stream."""
if not segments:
_LOGGER.error("Recording failed to capture anything")
return
if not os.path.exists(os.path.dirname(file_out)):
os.makedirs(os.path.dirname(file_out), exist_ok=True)