feat: Migrate watcher to use watchfiles library

The `watchfiles` library supports event batching, which allows us to
process multiple filesystem changes in a single run.

This change also avoids database calls in the watcher as much as
possible.
This commit is contained in:
Michael Manganiello
2025-08-07 13:01:45 -03:00
parent 1e6bfffe92
commit 76db0ab98c
5 changed files with 88 additions and 95 deletions

View File

@@ -201,11 +201,9 @@ start_bin_rq_worker() {
start_bin_watcher() {
info_log "Starting watcher"
watchmedo shell-command \
--patterns='**/*' \
--ignore-patterns='.DS_Store' \
--recursive \
--command='uv run python watcher.py "${watch_src_path}" "${watch_dest_path}" "${watch_event_type}" "${watch_object}"' \
watchfiles \
--target-type command \
'uv run python watcher.py' \
/romm/library &
WATCHER_PID=$!
echo "${WATCHER_PID}" >/tmp/watcher.pid