mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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:
parent
44ed6cda40
commit
715a254913
@ -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)
|
||||
|
||||
|
@ -193,6 +193,18 @@ async def test_recorder_discontinuity(tmpdir):
|
||||
assert os.path.exists(filename)
|
||||
|
||||
|
||||
async def test_recorder_no_segements(tmpdir):
|
||||
"""Test recorder behavior with a stream failure which causes no segments."""
|
||||
# Setup
|
||||
filename = f"{tmpdir}/test.mp4"
|
||||
|
||||
# Run
|
||||
recorder_save_worker("unused-file", [])
|
||||
|
||||
# Assert
|
||||
assert not os.path.exists(filename)
|
||||
|
||||
|
||||
async def test_record_stream_audio(
|
||||
hass, hass_client, stream_worker_sync, record_worker_sync
|
||||
):
|
||||
|
Loading…
x
Reference in New Issue
Block a user