Skip to content

Commit 19eaf23

Browse files
committed
delete_photo FileNotFoundError
1 parent 84b098d commit 19eaf23

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

coderbot/camera.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,11 @@ def get_photo_thumb_file(self, filename):
213213

214214
def delete_photo(self, filename):
215215
logging.info("delete photo: %s", filename)
216-
os.remove(PHOTO_PATH + "/" + filename)
217-
os.remove(PHOTO_PATH + "/" + filename[:filename.rfind(".")] + PHOTO_THUMB_SUFFIX + self._camera.PHOTO_FILE_EXT)
216+
try:
217+
os.remove(PHOTO_PATH + "/" + filename)
218+
os.remove(PHOTO_PATH + "/" + filename[:filename.rfind(".")] + PHOTO_THUMB_SUFFIX + self._camera.PHOTO_FILE_EXT)
219+
except FileNotFoundError:
220+
logging.warning("photo not found: %s", filename)
218221
for photo in self._photos:
219222
if photo["name"] == filename:
220223
self._photos.remove(photo)

0 commit comments

Comments
 (0)