Handle 'moved' events in serve_header.py #4997
Open
+6
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3659
Problem
The
serve_header.pyscript wasn't detecting when directories were moved into or out of the monitored root directory. This made the development workflow less smooth when reorganizing projects while the server was running.Root Cause
The
on_any_eventhandler only processed'created'and'deleted'events for directories, but file system watchers emit a separate'moved'event type that includes both source and destination paths.Solution
Added handling for
'moved'events on directories by treating them as a combination of:This mirrors how the filesystem actually handles move operations and ensures the working tree list stays in sync.
Testing
I tested this locally by:
The fix maintains backward compatibility and doesn't change behavior for other event types.