Skip to content

fix: keep sibling pages whose titles sanitise to the same filename - #33

Merged
blaipr merged 1 commit into
mainfrom
fix/recursive-download-name-collisions
Sep 2, 2026
Merged

blaipr merged 1 commit into
mainfrom
fix/recursive-download-name-collisions

Conversation

@blaipr

@blaipr blaipr commented Sep 2, 2026

Copy link
Copy Markdown
Member

Problem

safe_filename() is lossy: Setup: A and Setup A both become Setup_A, Q&A and QA both become QA. In download --recursive, each child was written to sub_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 in download_page tracks 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 --recursive takes 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 tests and python -m pytest tests/ pass
  • Tests added for the change (tests/test_recursive_download.py)
  • Docs updated (docs/usage.md, download section)
  • docs/conversion.md — not needed, no equivalence changed
  • CHANGELOG.md updated under Unreleased

@blaipr
blaipr force-pushed the fix/recursive-download-name-collisions branch from c9cdfd1 to c4abf67 Compare September 2, 2026 22:37
@blaipr
blaipr merged commit 973a734 into main Sep 2, 2026
1 check passed
@blaipr
blaipr deleted the fix/recursive-download-name-collisions branch September 2, 2026 22:37
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