Skip to main content

ModRepoClient

A class in TavernLib, TavernLib.Backend.Mods.

Fetches indexes and manifests from the trusted mod sources over NativeHttp. Runs off the main thread.

Constructors​

MemberWhat it is
ModRepoClient(NativeHttp http, List<string> repos, DateTime? deadlineUtc = null)Sets up the client with an HTTP helper, the repo URLs and an optional deadline.

Fields​

3 private and internal fields
MemberWhat it is
private const int JsonTimeoutSecondsTime allowed for one JSON fetch (15 seconds), shortened if the pass deadline is nearer.
private const long MaxJsonBytesLargest JSON download accepted (8 MB).
private const int SupportedIndexMajorThe repository index schema version this build reads (2).

Methods​

MemberWhat it is
ModIndex FetchIndexes()Downloads every source's index and merges them. For each mod and major, the default source wins, then the highest version.
ModManifest FetchLatest(string modId, string preferRepo)A mod's latest.json manifest, trying the preferred source first if it's trusted.
ModManifest FetchManifest(string modId, string version, string preferRepo)One version's manifest, trying the preferred source first. Throws if no source serves the right id and version.
static List<ModIncompatibility> IncompatibilitiesFrom(JObject index, string baseUrl)Reads a source index's incompatible list. An entry needs exactly two different mod ids and a string note; a below that isn't a version means every version clashes.
static List<ModReplacement> ReplacementsFrom(JObject index, string baseUrl)Reads a source index's replaced section, skipping malformed entries and ones that replace a mod with itself.
static void ValidateRepoIndex(string url)Throws ModManagerException unless the URL serves a version 2 repository.json with a mods object.
static List<ModWithdrawal> WithdrawalsFrom(JObject index, string baseUrl)Reads a source index's withdrawn object ({id: {version: reason}}), keeping string reasons only.
4 private and internal methods
MemberWhat it is
private ModManifest FetchManifestLeaf(string modId, string leaf, string preferRepo, string what, string expectedVersion)Fetches one manifest file for a mod, trying each repo with the preferred one first, and checks it names the right mod and version.
private ValueTuple<List<ModSummary>, List<ModReplacement>, List<ModIncompatibility>, List<ModWithdrawal>> FetchRepoIndex(string baseUrl)Fetches one source's index and returns its mods, replacements, incompatible pairs and withdrawn versions, or empty lists if it can't be read.
private JObject GetJson(string url)Downloads and parses a JSON object from a URL; throws ModManagerException on any failure.
private static bool IsSupported(JObject index)Returns whether an index has the integer index_version this build supports.

Used in​

Members of other types that take, return or hold a ModRepoClient: