Skip to content

Fix --from-logfile parsing when semicolons appear in paths - #7185

Merged
snejus merged 6 commits into
beetbox:masterfrom
boomesh11:fix-import-logfile-semicolon-in-paths
Nov 19, 2026
Merged

snejus merged 6 commits into
beetbox:masterfrom
boomesh11:fix-import-logfile-semicolon-in-paths

Conversation

@boomesh11

Copy link
Copy Markdown
Contributor

Problem

Fixes #4941.

When importing from a log file (beet import --from-logfile ...), paths recorded in the log file were split with paths.split("; "). If any path contained a semicolon in a directory or file name (e.g. Band; The/Album), it was split into multiple chunks where subsequent chunks were relative. Passing mixed absolute and relative segments to os.path.commonpath() raised:

ValueError: Can't mix absolute and relative paths

Solution

In paths_from_logfile, when log lines contain absolute paths, merge any subsequent non-absolute chunks back into the preceding absolute path before computing os.path.commonpath().

Tests

Added regression tests covering paths containing semicolons in directory names for both Windows and POSIX path formats.

When a path contains semicolons (e.g. in artist or directory names), splitting on '; ' split the path across multiple chunks. When the subsequent chunks were relative, os.path.commonpath raised ValueError: Can't mix absolute and relative paths.

This commit merges non-absolute segments back into preceding absolute paths before computing the commonpath.

Fixes beetbox#4941
@boomesh11
boomesh11 requested a review from a team as a code owner November 15, 2026 15:28
@github-actions

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.87%. Comparing base (a264a76) to head (4d48872).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7185   +/-   ##
=======================================
  Coverage   80.86%   80.87%           
=======================================
  Files         150      150           
  Lines       21234    21244   +10     
  Branches     3242     3245    +3     
=======================================
+ Hits        17171    17181   +10     
  Misses       3249     3249           
  Partials      814      814           
Files with missing lines Coverage Δ
beets/ui/commands/import_/__init__.py 54.47% <100.00%> (+4.02%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@snejus snejus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good - but create a function for this logic for maintainability reasons where the docstring explains what's happening there.

Also add a note to the changelog.

Comment thread beets/ui/commands/import_/__init__.py Resolved
@snejus
snejus enabled auto-merge November 19, 2026 20:38
@snejus
snejus added this pull request to the merge queue Nov 19, 2026
Merged via the queue into beetbox:master with commit ad27129 Nov 19, 2026
19 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.

--from-logfile parsing breaks when semicolons appear in paths

2 participants