Conversation
|
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. |
There was a problem hiding this comment.
🟡 Changes recommended
grug see real behavior bugs in unimported ignore-subdirectory traversal and permissions directory selection that can touch wrong folders, plus small message/doc fixes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
PR make Library.directory be pathlib.Path at runtime, and push “is this inside library?” logic into Library helper methods. This help reduce mixed bytes/str/path mess across importer, UI, models, and plugins.
Changes:
- Change
Library.directorytype toPath, addcontains_path()/is_in_directory()helpers, update callers to use them. - Update plugins and commands to use
Pathoperations (is_dir(),stat(),chmod(), joins) and onlyos.fsencode(...)at legacy boundaries. - Update tests/helpers to pass
Pathlibrary directories.
File summaries
| File | Description |
|---|---|
| test/test_library.py | Switch test setup to Path(...) for lib.directory. |
| test/plugins/test_permissions.py | Update permissions tests to use Path APIs and .filepath fields. |
| beetsplug/unimported.py | Migrate ignore/path logic to Path and Path joins. |
| beetsplug/permissions.py | Migrate permissions plugin to Path-based stat/chmod and path handling. |
| beetsplug/mbsync.py | Replace ancestry check with lib.is_in_directory(...). |
| beetsplug/ipfs.py | Construct temp library with directory=Path("/ipfs/"). |
| beetsplug/bpsync.py | Replace ancestry check with lib.is_in_directory(...). |
| beets/ui/commands/update.py | Use lib.is_in_directory(...) and Path.is_dir() for directory check. |
| beets/ui/init.py | Open library using config["directory"].as_path() and log Path values. |
| beets/test/helper.py | Pass Path into Library(...) in test harness. |
| beets/plugins.py | Replace ancestry check with lib.is_in_directory(...). |
| beets/library/models.py | Encode Path directory to bytes at legacy destination/move boundaries. |
| beets/library/library.py | Make directory: Path and add library path helper APIs. |
| beets/importer/tasks.py | Use session.lib.contains_path(...) for in-library checks. |
| beets/context.py | Accept PathLike for music-dir context, encode with os.fsencode. |
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## migrate-art-to-path #6991 +/- ##
=======================================================
- Coverage 76.92% 76.92% -0.01%
=======================================================
Files 163 163
Lines 21729 21734 +5
Branches 3348 3349 +1
=======================================================
+ Hits 16716 16719 +3
- Misses 4199 4200 +1
- Partials 814 815 +1
🚀 New features to boost your workflow:
|
64d10db to
a6166c4
Compare
a6166c4 to
8e5b774
Compare
Fixes #6967
What changed
Library.directorynow usespathlib.Pathinstead of string/bytes-style directory values.Library, with small helper APIs likecontains_path()andis_in_directory()replacing repeated ancestry checks across the codebase.os.fsencode(...).Architecture impact
beets.library.library.Libraryinstead of spreading low-level path checks across importers, UI commands, models, and plugins.PathobjectsPath.is_dir(),Path.chmod(),Path.stat(), andPathjoins, which reduces manual path handling.Why this matters
High-level impact for reviewers
Libraryhelpers orPathmethods.Library.directory; file placement and cleanup logic should remain the same.