Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractArchive(modFilePath string, modDirectory string) error
- func FindModsOnDisk() []types.InstalledMod
- func InstallModArchive(modFilePath string, modReference string) error
- func IsGameFeatureMod(modDirectory string, modReference string) (bool, error)
- func ReportOnDisk() []v2.InstalledMod
- func Sync(ctx context.Context, lf v2.Lockfile, progress func(int32, string)) ([]v2.InstalledMod, error)
- func UninstallMod(modReference string) error
- func WriteModConfigFile(modReference string, modConfig string) error
- type SyncPlan
Constants ¶
const GameFeaturesDirName = "GameFeatures"
GameFeaturesDirName is the subdirectory of Mods that the game loads game feature plugins from. A game feature mod placed alongside the ordinary mods is simply never loaded.
Variables ¶
var ErrNilMods = errors.New("syncmods payload has no mods list; refusing to uninstall every mod")
ErrNilMods is returned for a syncmods payload with no mods field at all.
nil and an explicit empty slice are NOT interchangeable, exactly as in the backend's agentmod.DeleteAbsent:
- lf.Mods == nil means the payload was absent, null, or {} — a malformed task. Executing it would put every mod on disk into plan.Remove and uninstall the lot on what is really a bug or a truncated message. Refuse it.
- lf.Mods == []v2.ModLock{} (non-nil, empty) means the backend resolved the set and it is genuinely empty — the user removed their last mod. That is a real outcome and MUST still wipe the Mods directory, or the last mod could never be removed.
Do not "simplify" this to a len() check: the two look identical there and mean opposite things.
Functions ¶
func ExtractArchive ¶
func FindModsOnDisk ¶
func FindModsOnDisk() []types.InstalledMod
func InstallModArchive ¶ added in v1.0.84
The GameFeature flag lives in the .uplugin inside the archive, so the target directory is not known until the archive has been unpacked. Extract to a staging directory first, read the manifest, then move it into place.
func IsGameFeatureMod ¶ added in v1.0.84
IsGameFeatureMod reads the GameFeature flag out of an unpacked mod's manifest.
func ReportOnDisk ¶ added in v1.0.84
func ReportOnDisk() []v2.InstalledMod
ReportOnDisk is the unconditional truth about the Mods directory, reported once on subscribe so a mod deleted by hand is noticed rather than believed installed forever.
func Sync ¶ added in v1.0.84
func Sync(ctx context.Context, lf v2.Lockfile, progress func(int32, string)) ([]v2.InstalledMod, error)
Sync brings the Mods directory to the lockfile's desired state and returns what it ended up with. The caller holds serverlock.
On failure it returns the report ALONGSIDE the error whenever it has already begun touching the disk: mods installed before the failing one are really on disk at their new version, and if the caller reported nothing the backend would keep believing the pre-sync installed-set until the next reconnect.
func UninstallMod ¶
func WriteModConfigFile ¶ added in v1.0.84
Types ¶
type SyncPlan ¶ added in v1.0.84
SyncPlan is what a sync will do. It is computed before anything is touched, so an empty plan short-circuits the whole task.