fix: bypass mtime check when file watcher triggers refresh#76
Merged
jfernandez merged 1 commit intojfernandez:mainfrom Mar 26, 2026
Merged
Conversation
The file watcher calls handle_markdown_file_change only after the OS reports a rename, create, or data modification event. Re-checking mtime inside refresh_file is redundant and fails when the renamed file has the same mtime as the original (sub-second filesystem granularity). Use force_refresh_file in the watcher path to unconditionally re-read the file. The mtime guard remains in refresh_file for the HTTP handler path where it prevents unnecessary disk reads on every page load. Also refactor refresh_file to delegate to force_refresh_file to avoid duplicating the read/parse logic.
jfernandez
approved these changes
Mar 26, 2026
adamatan
pushed a commit
to adamatan/mdserve
that referenced
this pull request
Apr 2, 2026
…z#76) The file watcher calls handle_markdown_file_change only after the OS reports a rename, create, or data modification event. Re-checking mtime inside refresh_file is redundant and fails when the renamed file has the same mtime as the original (sub-second filesystem granularity). Use force_refresh_file in the watcher path to unconditionally re-read the file. The mtime guard remains in refresh_file for the HTTP handler path where it prevents unnecessary disk reads on every page load. Also refactor refresh_file to delegate to force_refresh_file to avoid duplicating the read/parse logic.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The file watcher calls
handle_markdown_file_changeonly after the OS reports a rename, create, or data modification event. Re-checkingmtimeinsiderefresh_fileis redundant and fails when the renamed file has the samemtimeas the original (sub-second filesystem granularity).Use
force_refresh_filein the watcher path to unconditionally re-read the file. Themtimeguard remains inrefresh_filefor the HTTP handler path where it prevents unnecessary disk reads on every page load.Also refactor
refresh_fileto delegate toforce_refresh_fileto avoid duplicating the read/parse logic.