Expand description
Schema-driven, root-relative mod install routing. Schema-driven, root-relative mod install routing.
Given a package’s extracted contents and a game’s
GameProfile from the Thunderstore ecosystem
schema, this module computes an InstallPlan: a
list of source files mapped to destination paths relative to a profile/loader
root. The caller supplies the absolute root and applies the plan with
apply_install, which records a
FileManifest of every written path so
uninstall is exact and reversible.
Routing is driven entirely by the schema’s install rules (no per-game code):
a package’s override folders route by matching a rule’s route leaf, loose files
route by longest-matching extension, and anything else falls to the rule flagged
as the default location. A package that appears in the ecosystem’s mod-loader
registry (Ecosystem::modloader_package)
is instead unpacked to the root.
Deliberately, this module does NOT resolve the absolute game directory, do Steam/Epic discovery, or place the loader proxy next to the executable — those are game-specific concerns left to the caller.
Structs§
- File
Manifest - Records every path written by
apply_install, for exact uninstall. - Install
Entry - A single source -> destination mapping within an install plan.
- Install
Plan - A computed, root-relative plan for installing one package.
- ModFile
Tracker - Records the files a
State-tracked mod installed, so enable/disable can undo and redo them. Mirrors r2modman’s_state/<mod>-state.ymlModFileTracker: each pair is(cache source path, profile-relative install path).
Functions§
- apply_
install - Applies an install plan into
root, copying files and recording what was written. - clear_
state_ files - Removes a mod’s
State-tracked payload files but keeps its_statefile, so a reinstall that fails before writing a new one still leaves the record thatremove_state_payloadneeds to uninstall the mod. A missing_statefile is a no-op. - disable_
mod - Disables an installed mod: renames its
Subdir-tracked files to.oldand removes itsState-tracked files (recoverable via the_statefile on enable). Leaves shared/noneconfig and the loader untouched. - enable_
mod - Enables an installed mod: strips
.oldfrom itsSubdir-tracked files and restores itsState-tracked files by copying them back from the cache sources recorded in the_statefile. - plan_
delisted - The
<Owner-Name>-shaped mod folders underprofile’s namespaced install routes thatkeepdoes not name, as root-relative paths. These are exactly the directoriesremove_delistedwould delete. - plan_
install - Builds an
InstallPlanfor a package. - plan_
is_ on_ disk - Whether every file
plantracks is still on disk underroot, so a mod recorded at the planned version can be skipped instead of reinstalled. - plan_
suffix_ renames - Computes the rename each file needs to toggle its enabled state, omitting
files already in the desired state. Disabling appends
.oldto a file that does not already end in.old; enabling strips a trailing.old. Pure — no I/O — so the policy is table-testable (mirrorsclassify_entry). - read_
state_ file - Reads a mod’s state tracker, or
Noneif the file does not exist. - remove_
delisted - Reconciles the on-disk install to a desired set, removing the folders of mods that are no longer wanted, without any sidecar state file.
- remove_
mod_ folders - Removes one mod’s
<route>/<ident>/folder under every namespaced route, so a reinstall starts from an empty folder instead of writing beside files the new version no longer ships (or a disabled install’s.oldfiles). - remove_
state_ file - Removes a mod’s
_statefile, if it has one, leaving any payload files it names in place. - remove_
state_ payload - Removes a mod’s
State-tracked payload files and then its_statefile, so an uninstall leaves nothing behind for a mod whose files live under non-namespaced routes (whichremove_delisteddoes not reconcile). - state_
file_ path - The
_state/<mod_name>-state.ymlpath within a profile directory. - state_
tracker_ from_ plan - Collects the
State-tracked entries ofplaninto aModFileTracker, orNonewhen the plan installs noStatefiles. Pure — no I/O. - write_
state_ file - Writes a mod’s state tracker to
<profile_dir>/_state/<mod>-state.yml.