Revamp update check logic
Pathoschild opened this issue ยท 2 comments
Revamp SMAPI's update check logic to handle preview versions (e.g. optional versions on Nexus), simplify the clientside logic, and support upcoming lookups by mod ID.
How it works now
SMAPI submits a request to the web API with a list of update keys:
POST https://api.smapi.io/v2.6/mods
{
"ModKeys": [ "nexus:541", "chucklefish:4250", ... ]
}
The API then responds with info for each update key:
{
"chucklefish:4250": {
"name": "Lookup Anything",
"version": "*",
"url": "https://community.playstarbound.com/resources/4250",
"error": "Mod has invalid semantic version '*'."
},
"nexus:541": {
"name": "Lookup Anything",
"version": "1.19-beta.7",
"url": "https://www.nexusmods.com/stardewvalley/mods/541"
}
}
That's pretty simple for the API, but has some disadvantages for SMAPI and other clients. It's up to them to...
- aggregate multiple update keys for each mod;
- aggregate errors (e.g. in the above example, one source failed but not the other);
- match update keys back to each mod (e.g. if two mods share an update key);
- provide the mod's update keys. (SMAPI has an internal list for older mods which don't provide their own, but that list is only updated when you update SMAPI itself. It also doesn't help non-SMAPI tools like mod managers.)
Proposed implementation
SMAPI submits a request with the mod ID and optional update keys for each mod it wants info for:
POST https://api.smapi.io/v2.6/mods
{
"Mods": [
{
"ID": "Pathoschild.LookupAnything",
"UpdateKeys": [ "Nexus:541", "GitHub:Pathoschild/LookupAnything" ]
}
]
}
The API will then return aggregated info for each ID. It will handle figuring out which version is latest (for both main and preview if applicable), aggregate errors, etc. In future versions it will use the ID to lookup update keys automatically based on its internal DB and the wiki list.
{
"Pathoschild.LookupAnything": {
"id": "Pathoschild.LookupAnything",
"name": "Lookup Anything",
"version": "1.19-beta.7",
"url": "https://www.nexusmods.com/stardewvalley/mods/541"
}
}