You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix prevent dangling symlink from crashing the build (#43)
* fix: prevent dangling symlink from crashing the build
A dangling symlink in the docs directory would crash `mkdocs build` with an
unhandled FileNotFoundError during file copy. `os.walk` lists the symlink as
a regular file, but when `shutil.copyfile` (or `os.path.getmtime`) follows
the symlink to a missing target, the uncaught OSError aborts the entire build.
Fix:
- `is_modified()`: catch OSError when calling getmtime on the source — return
False so the file is skipped silently.
- `copy_file()`: catch OSError around copy and log a warning, then skip the
file gracefully instead of crashing.
Closes: mkdocs/mkdocs#4048
* docs: add release note for dangling symlink crash fix
* Apply suggestions from code review
Co-authored-by: Xianpeng Shen <xianpeng.shen@gmail.com>
* FIx trim trailing whitespace
* fix: resolve log routing conflict between two dangling symlink fixes
PR #3785 added early broken-symlink detection in utils.copy_file() that
logged a warning and returned early. PR #4048 added an except OSError
handler in files.py expecting the exception to propagate. Because the
early return short-circuited before shutil.copyfile, the OSError handler
was never reached, and the mkdocs.utils warning leaked to lastResort.
Fix: raise FileNotFoundError in utils.copy_file() instead of logging,
allowing the existing except OSError handler in files.py to catch it
and log with the mkdocs.structure.files logger as expected.
Copy file name to clipboardExpand all lines: docs/about/release-notes.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,7 @@ The current members of the MkDocs-NG team.
43
43
* Fix `validation.links.not_found` is always reported as INFO for excluded pages. #32
44
44
* Fix `mkdocs serve` cleanup so temporary site directories are removed when the process receives `SIGTERM`. #36
45
45
* Fix mkdocs theme color mode switching when `highlightjs` is disabled. #39
46
+
* Fix a crash when a dangling symlink exists in the docs directory, so `mkdocs build` and `mkdocs serve` log a warning and continue instead of aborting. #43
0 commit comments