MCPcopy
hub / github.com/open-webui/mcpo / on_modified

Method on_modified

src/mcpo/utils/config_watcher.py:27–49  ·  view source on GitHub ↗

Handle file modification events.

(self, event)

Source from the content-addressed store, hash-verified

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)."""

Callers

nothing calls this directly

Calls 1

_trigger_reloadMethod · 0.95

Tested by

no test coverage detected