Skip to content

Commit

Permalink
delete_photo FileNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
previ committed Dec 30, 2024
1 parent 84b098d commit 19eaf23
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions coderbot/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ def get_photo_thumb_file(self, filename):

def delete_photo(self, filename):
logging.info("delete photo: %s", filename)
os.remove(PHOTO_PATH + "/" + filename)
os.remove(PHOTO_PATH + "/" + filename[:filename.rfind(".")] + PHOTO_THUMB_SUFFIX + self._camera.PHOTO_FILE_EXT)
try:
os.remove(PHOTO_PATH + "/" + filename)
os.remove(PHOTO_PATH + "/" + filename[:filename.rfind(".")] + PHOTO_THUMB_SUFFIX + self._camera.PHOTO_FILE_EXT)
except FileNotFoundError:
logging.warning("photo not found: %s", filename)
for photo in self._photos:
if photo["name"] == filename:
self._photos.remove(photo)
Expand Down

0 comments on commit 19eaf23

Please sign in to comment.