Update shortcut removal to rely on menuinst.toml#1
Conversation
| """Get recorded shortcut paths for a source from menuinst.toml.""" | ||
| data = read_menuinst_toml(prefix) | ||
| shortcuts = data.get("shortcuts", []) | ||
| return [s["path"] for s in shortcuts if s.get("source") == source and "path" in s] |
There was a problem hiding this comment.
Should they be sources be converted into Path objects to not depend on string shenanigans? Or maybe even use Path.same_file()?
There was a problem hiding this comment.
I think the idea is good but here we are unfortunately comparing filename strings (basename) and not the actual path on disk so unfortunately Path.samefile is not applicable.
|
Before I review this in detail, I have a more general question: you use the API-level removal function to remove the shortcuts if loaded from TOML. Have you considered to instead just load the paths from the TOML file? Maybe as an optional input parameter for That way, we don't have to touch any of the existing removal methods and keep everything located inside the classes. |
Description
Use recorded paths from
menuinst.tomlfor removal instead of recomputing from JSON. Falls back to computed paths for legacy installs.api.pyget_recorded_paths(),delete_paths()remove()now checks TOML first, falls back to computed paths. I wasn't sure if it's totally safe to remove the "old code", I was thinking that there might be a scenario where packages are installed, then menuinst is updated to a version withmenuinst.toml, but the shortcuts installed before the update are not tracked in the.tomlfile.install()records MenuItem paths (not Menu paths) to TOMLPlatform files (
win.py,osx.py,linux.py)remove()intodelete_paths()+cleanup_side_effects(). When using TOML paths,api.remove()handles file deletion directly (it has the TOML data). But platform-specific cleanup (registry, LaunchServices, MIME etc.) still needs the MenuItem objects. Separating these two letsapi.pydelete files from TOML data while platforms handle their own side-effects.remove()preserved (calls both)Removal Flow
To simplify the review, this is the removal flow:
Checklist - did you ...
newsdirectory (using the template) for the next release's release notes?