mirror of
https://github.com/nlohmann/json.git
synced 2026-01-19 04:52:10 +00:00
Handle 'moved' events in serve_header.py (#4997)
Fixes #3659 I was testing serve_header.py with my local development setup and noticed that when I moved directories into or out of the monitored root, they weren't being picked up properly. The script would only detect create and delete events but not move operations. This was happening because the on_any_event handler only checked for 'created' and 'deleted' events on directories. Move events have a separate event type 'moved' that includes both the source and destination paths. The fix treats a move event like a combination of delete (for the source) and create (for the destination) - we rescan to remove any trees that were moved out, and add the destination directory to check for new trees that were moved in. This should make the development workflow smoother when reorganizing project directories while the server is running. Signed-off-by: Samaresh Kumar Singh <ssam3003@gmail.com>
This commit is contained in:
@@ -231,6 +231,12 @@ class WorkTrees(FileSystemEventHandler):
|
||||
elif event.event_type == 'deleted':
|
||||
# check for deleted working trees
|
||||
self.rescan(path)
|
||||
elif event.event_type == 'moved':
|
||||
# handle moved directories - treat source as deleted and dest as created
|
||||
self.rescan(path)
|
||||
if hasattr(event, 'dest_path'):
|
||||
dest_path = os.path.abspath(event.dest_path)
|
||||
self.created_bucket.add_dir(dest_path)
|
||||
elif event.event_type == 'closed':
|
||||
with self.tree_lock:
|
||||
for tree in self.trees:
|
||||
|
||||
Reference in New Issue
Block a user