Skip to content

[filewatcher] Ignore file changes with same content#2511

Merged
justvanrossum merged 6 commits intomainfrom
filewatcher-ignore-by-content-hash
Mar 23, 2026
Merged

[filewatcher] Ignore file changes with same content#2511
justvanrossum merged 6 commits intomainfrom
filewatcher-ignore-by-content-hash

Conversation

@justvanrossum
Copy link
Copy Markdown
Member

@justvanrossum justvanrossum commented Mar 23, 2026

Windows + OneDrive storage gives an interesting behavior: after we write a file, OneDrive will touch the file after about a second. The content doesn't change, but the modification time does, so we'll get a "file changed" event. But since the modified time is now different from when we wrote the file, the change gets interpreted as an external change, and will cause data to be reloaded. This is especially clear to observe when editing the OpenType features for a UFO: the cursor will jump back to the beginning of the document soon after any edit.

Solution: we will do extra work and record a hash for the contents of any file written, and will use that to compare with the hash of the file when receiving a file changed event. If it's the same, we ignore the event.

TODO:

  • Add a test

@justvanrossum justvanrossum changed the title [filewatcher] Ignore file changes with same content hash [filewatcher] Ignore file changes with same content Mar 23, 2026
@justvanrossum justvanrossum merged commit ae447a8 into main Mar 23, 2026
4 checks passed
@justvanrossum justvanrossum deleted the filewatcher-ignore-by-content-hash branch March 23, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant