Skip to main content

Module install

Module install 

Source
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§

FileManifest
Records every path written by apply_install, for exact uninstall.
InstallEntry
A single source -> destination mapping within an install plan.
InstallPlan
A computed, root-relative plan for installing one package.
ModFileTracker
Records the files a State-tracked mod installed, so enable/disable can undo and redo them. Mirrors r2modman’s _state/<mod>-state.yml ModFileTracker: 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 _state file, so a reinstall that fails before writing a new one still leaves the record that remove_state_payload needs to uninstall the mod. A missing _state file is a no-op.
disable_mod
Disables an installed mod: renames its Subdir-tracked files to .old and removes its State-tracked files (recoverable via the _state file on enable). Leaves shared/none config and the loader untouched.
enable_mod
Enables an installed mod: strips .old from its Subdir-tracked files and restores its State-tracked files by copying them back from the cache sources recorded in the _state file.
plan_delisted
The <Owner-Name>-shaped mod folders under profile’s namespaced install routes that keep does not name, as root-relative paths. These are exactly the directories remove_delisted would delete.
plan_install
Builds an InstallPlan for a package.
plan_is_on_disk
Whether every file plan tracks is still on disk under root, 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 .old to a file that does not already end in .old; enabling strips a trailing .old. Pure — no I/O — so the policy is table-testable (mirrors classify_entry).
read_state_file
Reads a mod’s state tracker, or None if 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 .old files).
remove_state_file
Removes a mod’s _state file, 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 _state file, so an uninstall leaves nothing behind for a mod whose files live under non-namespaced routes (which remove_delisted does not reconcile).
state_file_path
The _state/<mod_name>-state.yml path within a profile directory.
state_tracker_from_plan
Collects the State-tracked entries of plan into a ModFileTracker, or None when the plan installs no State files. Pure — no I/O.
write_state_file
Writes a mod’s state tracker to <profile_dir>/_state/<mod>-state.yml.