mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Prevent Verisure cam to delete a file when it is None (#3988)
This commit is contained in:
parent
0fce5ccc7f
commit
678f30def1
@ -4,6 +4,7 @@ Camera that loads a picture from a local file.
|
|||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/camera.verisure/
|
https://home-assistant.io/components/camera.verisure/
|
||||||
"""
|
"""
|
||||||
|
import errno
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -74,12 +75,8 @@ class VerisureSmartcam(Camera):
|
|||||||
hub.my_pages.smartcam.download_image(self._device_id,
|
hub.my_pages.smartcam.download_image(self._device_id,
|
||||||
new_image_id,
|
new_image_id,
|
||||||
self._directory_path)
|
self._directory_path)
|
||||||
if self._image_id:
|
_LOGGER.debug('Old image_id=%s', self._image_id)
|
||||||
_LOGGER.debug('Old image_id=%s', self._image_id)
|
self.delete_image(self)
|
||||||
self.delete_image(self)
|
|
||||||
|
|
||||||
else:
|
|
||||||
_LOGGER.debug('No old image, only new %s', new_image_id)
|
|
||||||
|
|
||||||
self._image_id = new_image_id
|
self._image_id = new_image_id
|
||||||
self._image = os.path.join(self._directory_path,
|
self._image = os.path.join(self._directory_path,
|
||||||
@ -93,8 +90,12 @@ class VerisureSmartcam(Camera):
|
|||||||
'{}{}'.format(
|
'{}{}'.format(
|
||||||
self._image_id,
|
self._image_id,
|
||||||
'.jpg'))
|
'.jpg'))
|
||||||
_LOGGER.debug('Deleting old image %s', remove_image)
|
try:
|
||||||
os.remove(remove_image)
|
os.remove(remove_image)
|
||||||
|
_LOGGER.debug('Deleting old image %s', remove_image)
|
||||||
|
except OSError as error:
|
||||||
|
if error.errno != errno.ENOENT:
|
||||||
|
raise
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user