fix: keep sibling pages whose titles sanitise to the same filename - #33
Merged
Merged
Conversation
blaipr
force-pushed
the
fix/recursive-download-name-collisions
branch
from
September 2, 2026 22:37
c9cdfd1 to
c4abf67
Compare
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.
Problem
safe_filename()is lossy:Setup: AandSetup Aboth becomeSetup_A,Q&AandQAboth becomeQA. Indownload --recursive, each child was written tosub_dir / f"{safe_filename(title)}.md"with no check for a sibling already at that path, so the second page silently overwrote the first — the tree on disk was missing a page and nothing said so.Change
A new
unique_filename(stem, used)helper gives the first sibling the plain stem and later colliding ones a numeric suffix (Setup_A_2,Setup_A_3, ...), comparing case-insensitively because the common desktop filesystems do. The child loop indownload_pagetracks the stems used per folder and routes each name through it. The single-page download path is untouched.Compatibility
Download only. Trees without colliding titles are written exactly as before.
upload --recursivetakes the page title from the file's# Heading(and the target page from its version marker), so a suffixed filename uploads to the right page unchanged.Checklist
ruff check src tests,ruff format --check src testsandpython -m pytest tests/passtests/test_recursive_download.py)docs/usage.md, download section)docs/conversion.md— not needed, no equivalence changedCHANGELOG.mdupdated under Unreleased