Closed nickcharlesyt closed 1 month ago
Attached is a debug log, this has two file events captured at 11:26 local time, note how many log entries there are from folder watcher for those two new files:
So I took a look at the last file and first it has a created event, then some modified events and then lastly a closed event. So I would say it's working as expected?
2024-09-17 11:26:25.526 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileCreatedEvent: event_type=created, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.530 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.532 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.540 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.541 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.559 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.595 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.631 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.632 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.634 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.634 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileClosedEvent: event_type=closed, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
2024-09-17 11:26:25.636 DEBUG (Thread-2) [homeassistant.components.folder_watcher] process(<FileModifiedEvent: event_type=modified, src_path='/config/www/New/Doorbell.20240917_112607.mp4', is_directory=False)
Issue resolved (discussion on discord). Automation issue rather than issue with folder_watcher
The problem
I'm attempting to use a folder watcher event to check for when a file gets copied over to the www directory to be served as part of an automation. The integration is configured to check the /config/www/New folder for *.mp4 file patterns to monitor. A bash shell script is being used to copy the file to this location from a network share for temporary access, it is then deleted after 1 day using a second bash script. I will provide the current shell script in use at the end.
When these folder watcher events come in through the logbook, I am getting anywhere from 6-12 or so log entries for the same file copy event, all arriving instantaneously within the logbook at the exact same second. All entries are for a "modified" event state, I never see a "created" event. In the previous version of core (2024.9.1) they were all coming in as a "closed" state, again no "created" event. For example, here are the 10 log entries received for one file that arrived 28 minutes ago, all report "modified":
I see the same duplicate entries for the "deleted" state when my hourly cleanup job runs, unfortunately I don't currently have examples of this as I cleared out the folder manually while testing something else.
What version of Home Assistant Core has the issue?
core-2024.9.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Folder Watcher
Link to integration documentation on our website
https://www.home-assistant.io/integrations/folder_watcher/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
shell script in use for move command:
!/bin/bash
for i in {1..10}; do if cp "$1" "/config/www/New/$2"; then chmod 644 "/config/www/New/$2" echo "Succeeded after $i attempt(s) and set file permissions" >&2 exit 0 else sleep 5 fi done echo "Failed after 10 attempts" >&2 exit 1