Skip to content

fix: bypass mtime check when file watcher triggers refresh#76

Merged
jfernandez merged 1 commit intojfernandez:mainfrom
JacobAMason:fix-watcher-mtime-bypass
Mar 26, 2026
Merged

fix: bypass mtime check when file watcher triggers refresh#76
jfernandez merged 1 commit intojfernandez:mainfrom
JacobAMason:fix-watcher-mtime-bypass

Conversation

@JacobAMason
Copy link
Copy Markdown
Contributor

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.

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 jfernandez merged commit e94a3fa into jfernandez:main Mar 26, 2026
9 checks passed
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.
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.

2 participants