fix: handle permission errors when saving recordings

pull/106/head
Jeff Culverhouse 3 months ago
parent 2060e87750
commit bf54589328

@ -20,13 +20,11 @@ if TYPE_CHECKING:
READY_FILE = os.getenv("READY_FILE", "/tmp/amcrest2mqtt.ready")
class ConfigError(ValueError):
"""Raised when the configuration file is invalid."""
pass
class HelpersMixin:
async def build_device_states(self: Amcrest2Mqtt, device_id: str) -> bool:
if self.is_rebooting(device_id):
@ -265,9 +263,15 @@ class HelpersMixin:
try:
file_path.write_bytes(recording.encode("latin-1"))
except PermissionError as err:
self.logger.error(f"permission error saving recording to {file_path}: {err!r}")
return None
except IOError as err:
self.logger.error(f"failed to save recording to {file_path}: {err!r}")
return None
except Exception as err:
self.logger.error(f"failed to save recording to {file_path}: {err!r}")
return None
self.upsert_state(
device_id,

Loading…
Cancel
Save