Repository navigation
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.
❌ 4 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
a6166c4 to
8e5b774
Compare
12f4622 to
011800c
Compare
5731142 to
ad3ab58
Compare
ad3ab58 to
670dde8
Compare
8e5b774 to
7498ef1
Compare
670dde8 to
78f8964
Compare
9799eb0 to
05306d0
Compare
|
Dear maintainers,
I just realised that this PR would break your plugins/scripts. There is no easy to way to make Would you be able to update your plugins/scripts to handle Thank you! |
eedea2e to
08aa064
Compare
08aa064 to
86279b7
Compare
Fixes #6967
Summary
Library.directoryis now apathlib.Pathinstead ofbytes, and the constructor accepts any path-like value for it.Library.contains_path()andLibrary.is_in_directory()replace thelib.directory in util.ancestry(item.path)idiom, which was repeated across thirteen call sites in the importer,update,mbsync,bpsync,plugins.apply_item_changesandItem.try_sync.permissionsandunimportednow work withPaththroughout. Both of them matched the library root by string prefix before, so/musicalso matched/music2andignore_subdirectories: [pod]also skippedpodcasts/- both fixed here.os.fsencode()instead of threading the conversion through.Tests
TestLibraryDirectorycoversPath,strandbytesdirectory arguments.test/plugins/test_unimported.pycoveringignore_extensions, including compound ones liketar.gz.test_permissions.pyupdated for thePathsignatures.Notes
lib.directorywithos.pathhelpers, or compare it againstbytes, will break. Changelog entry is under "For plugin developers".ignore_extensionsmatching became case-insensitive as a side effect, sojpgnow coverscover.JPGtoo. Also in the changelog.get_music_dir()still returnsbytes, so that part of MakeLibrary.directoryand music-directory context Path-based #6967 isn't done. I'd rather leave it for the follow-up which migrates thedbcorepath queries, since nothing else can consume aPathfrom it yet.