Skip to content

fix(images): disambiguate relative images that share a basename#160

Merged
KylinMountain merged 1 commit into
mainfrom
fix/image-basename-collision
Jul 2, 2026
Merged

fix(images): disambiguate relative images that share a basename#160
KylinMountain merged 1 commit into
mainfrom
fix/image-basename-collision

Conversation

@KylinMountain

Copy link
Copy Markdown
Collaborator

Two relative source images with the same basename but different paths (e.g. a/logo.png and b/logo.png) overwrote each other in sources/images/<doc>/, collapsing both Markdown links onto a single file. This tracks the destination assigned to each source (so an image referenced twice is copied once) and suffixes genuine basename collisions (logo.pnglogo_1.png).

Provenance

Supersedes #122 by @jichaowang02-lang — this lands that PR's first commit (the correct fix, with its tests) and drops its second commit, which seeded the taken-name set from the existing images_dir and broke re-convert idempotency (a changed same-basename image got a fresh suffix on every run, orphaning the old file and churning links — the point raised in review on #122). Credited via Co-authored-by.

Verification

ruff check ✓ · ruff format --check ✓ · mypy openkb ✓ · pytest 919 passed (incl. the new collision + dedup cases in tests/test_images.py).

Closes #122.

https://claude.ai/code/session_01UtbmJxjtw6FtP8fUXUKVtg

Two relative source images with the same basename but different paths
(e.g. a/logo.png and b/logo.png) overwrote each other in
sources/images/<doc>/, collapsing both markdown links onto one file.
Track the destination assigned to each source (so an image referenced
twice is copied once) and suffix genuine basename collisions
(logo.png -> logo_1.png).

Adapted from #122 by @jichaowang02-lang; drops that PR's second commit,
which seeded the taken-name set from the existing images_dir and thereby
broke re-convert idempotency (a changed same-basename image got a fresh
suffix each run, orphaning the old file and churning links).

Co-authored-by: jichao wang <jichaowang02@gmail.com>
Claude-Session: https://claude.ai/code/session_01UtbmJxjtw6FtP8fUXUKVtg
@KylinMountain KylinMountain merged commit dce4972 into main Jul 2, 2026
2 checks passed
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