How to check if picture is uptodate

Hello,

I have an automation that is triggered by a button (doorbell)
The action is taking a picture from a esp32-cam programmed with esphome and send the picture to telegram.

I have this code:

    - service: camera.snapshot
      data:
        entity_id: camera.esp32cam01
        filename: '/home/homeassistant/.homeassistant/www/camerapictures/doorbell.jpg'

If the camare is disconnected the file is not replaced and an old picture is sent.

I can add a condition of “when camera is online”, and make an other automation that is triggered if not and send a telegram that camera is down (but doorbell is pushed).

Other way could be: Check if file exists before sending and if so send picture and delete it after sending the telegram. Is this possible?