fix(images): disambiguate relative images that share a basename#160
Merged
Conversation
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
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.
Two relative source images with the same basename but different paths (e.g.
a/logo.pngandb/logo.png) overwrote each other insources/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.png→logo_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_dirand 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 viaCo-authored-by.Verification
ruff check✓ ·ruff format --check✓ ·mypy openkb✓ ·pytest919 passed (incl. the new collision + dedup cases intests/test_images.py).Closes #122.
https://claude.ai/code/session_01UtbmJxjtw6FtP8fUXUKVtg