Handle file modification events.
(self, event)
| 25 | self._debounce_delay = 0.5 # 500ms debounce |
| 26 | |
| 27 | def on_modified(self, event): |
| 28 | """Handle file modification events.""" |
| 29 | if self.is_symlink: |
| 30 | self.config_path = self.origin_config_path.resolve() # Re-resolve to get the latest symlink target |
| 31 | logger.info(f"Symlink file modified: {self.config_path}") |
| 32 | self._trigger_reload() |
| 33 | return |
| 34 | |
| 35 | if event.is_directory: |
| 36 | return |
| 37 | |
| 38 | # Check if the modified file is our config file |
| 39 | event_path = Path(event.src_path).resolve() |
| 40 | logger.debug(f"File modified: {event_path}, watching: {self.config_path}") |
| 41 | |
| 42 | # Also check for file name match in case of temporary files or atomic writes |
| 43 | if (event_path == self.config_path or |
| 44 | event_path.name == self.config_path.name and event_path.parent == self.config_path.parent): |
| 45 | |
| 46 | logger.info(f"Config file modified: {self.config_path}") |
| 47 | self._trigger_reload() |
| 48 | else: |
| 49 | logger.debug(f"File {event_path} modified but not our config file {self.config_path}") |
| 50 | |
| 51 | def on_moved(self, event): |
| 52 | """Handle file move events (atomic writes).""" |
nothing calls this directly
no test coverage detected