Skip to content

Commit 4b8db07

Browse files
committed
Handle 'moved' events in serve_header.py
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 <[email protected]>
1 parent 49026f7 commit 4b8db07

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/serve_header/serve_header.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ def on_any_event(self, event):
231231
elif event.event_type == 'deleted':
232232
# check for deleted working trees
233233
self.rescan(path)
234+
elif event.event_type == 'moved':
235+
# handle moved directories - treat source as deleted and dest as created
236+
self.rescan(path)
237+
if hasattr(event, 'dest_path'):
238+
dest_path = os.path.abspath(event.dest_path)
239+
self.created_bucket.add_dir(dest_path)
234240
elif event.event_type == 'closed':
235241
with self.tree_lock:
236242
for tree in self.trees:

0 commit comments

Comments
 (0)