Skip to content

Canonicalize scanned paths to avoid self-duplicates - #6

Merged
zas merged 1 commit into
zas:mainfrom
ad-si:fix/canonicalize-scan-paths
Jul 10, 2026
Merged

zas merged 1 commit into
zas:mainfrom
ad-si:fix/canonicalize-scan-paths

Conversation

@ad-si

@ad-si ad-si commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

WalkDir yields paths relative to the base argument, so scanning . stored ./song.mp3 while scanning an absolute path stored the full path. The same physical file reached via different spellings landed in the DB twice (the path column is UNIQUE but keyed on the string) and was reported as an "exact copy" duplicate of itself.

Canonicalize each discovered path before storing so one physical file always maps to one absolute, symlink-resolved path. This also makes scan consistent with exclude/include/find --for, which already canonicalize.

WalkDir yields paths relative to the base argument, so scanning "."
stored "./song.mp3" while scanning an absolute path stored the full
path. The same physical file reached via different spellings landed in
the DB twice (the path column is UNIQUE but keyed on the string) and was
reported as an "exact copy" duplicate of itself.

Canonicalize each discovered path before storing so one physical file
always maps to one absolute, symlink-resolved path. This also makes scan
consistent with exclude/include/`find --for`, which already canonicalize.

@zas zas left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, LGTM.

As an improvement, we could store the original (non-canonicalized) path as the display path, so output and --exec reference the path the user actually sees in their filesystem.

@zas
zas merged commit 440ee28 into zas:main Jul 10, 2026
5 checks passed
@ad-si
ad-si deleted the fix/canonicalize-scan-paths branch July 10, 2026 14:40
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.

2 participants