From de18f2b9fee43b40090db35967b98bdcac6fc477 Mon Sep 17 00:00:00 2001 From: Alex <25013571+alexhb1@users.noreply.github.com> Date: Tue, 3 Mar 2026 18:00:48 +0000 Subject: [PATCH] Fix: File movement trigger event (#691) Creates IN_MOVED_TO event, fixes CWA ingest folder detection when file movement fallback occurs --- shelfmark/download/fs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shelfmark/download/fs.py b/shelfmark/download/fs.py index 5c5c30de..4eae56bd 100644 --- a/shelfmark/download/fs.py +++ b/shelfmark/download/fs.py @@ -289,6 +289,13 @@ def _publish_temp_file(temp_path: Path, dest_path: Path) -> bool: """ try: run_blocking_io(os.link, str(temp_path), str(dest_path)) + # Trigger IN_CLOSE_WRITE so inotify-based file watchers (e.g. CWA) detect the new file. + # os.link() only generates IN_CREATE which many watchers don't monitor. + try: + fd = run_blocking_io(os.open, str(dest_path), os.O_WRONLY) + run_blocking_io(os.close, fd) + except OSError: + pass run_blocking_io(temp_path.unlink, missing_ok=True) return True except FileExistsError: