Skip to content

Commit 6a1e895

Browse files
committed
Use API mirror to update mods if enabled
1 parent 09b3adf commit 6a1e895

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ and only contains the latest changes.
33
Its purpose is to be shown in Olympus when updating.
44

55
#changelog#
6-
Added more mirror options for people that cannot access maddie480.ovh
6+
Use API mirror to update mods if enabled

sharp/CmdUpdateAllMods.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
using System.Security.Cryptography;
99

1010
namespace Olympus {
11-
public class CmdUpdateAllMods : Cmd<string, bool, string, IEnumerator> {
11+
public class CmdUpdateAllMods : Cmd<string, bool, string, bool, IEnumerator> {
1212
public override bool Taskable => true;
1313

14-
public override IEnumerator Run(string root, bool onlyEnabled, string mirrorPreferences) {
14+
public override IEnumerator Run(string root, bool onlyEnabled, string mirrorPreferences, bool apiMirror) {
1515
yield return "Downloading mod versions list...";
16-
Dictionary<string, ModUpdateInfo> modVersionList = downloadModUpdateList();
16+
Dictionary<string, ModUpdateInfo> modVersionList = downloadModUpdateList(apiMirror);
1717

1818
yield return "Checking for outdated mods...";
1919

@@ -186,11 +186,11 @@ private static void log(string line) {
186186
/// Downloads the full update list from the update checker server.
187187
/// Returns null if the download fails for any reason.
188188
/// </summary>
189-
private static Dictionary<string, ModUpdateInfo> downloadModUpdateList() {
189+
private static Dictionary<string, ModUpdateInfo> downloadModUpdateList(bool apiMirror) {
190190
Dictionary<string, ModUpdateInfo> updateCatalog = null;
191191

192192
try {
193-
string modUpdaterDatabaseUrl = getModUpdaterDatabaseUrl();
193+
string modUpdaterDatabaseUrl = getModUpdaterDatabaseUrl(apiMirror);
194194

195195
log($"Downloading last versions list from {modUpdaterDatabaseUrl}");
196196

@@ -252,7 +252,9 @@ private static void installModUpdate(ModUpdateInfo update, CmdModList.ModInfo mo
252252
/// Retrieves the mod updater database location from everestapi.github.io.
253253
/// This should point to a running instance of https://github.com/maddie480/EverestUpdateCheckerServer.
254254
/// </summary>
255-
private static string getModUpdaterDatabaseUrl() {
255+
private static string getModUpdaterDatabaseUrl(bool apiMirror) {
256+
if (apiMirror) return "https://everestapi.github.io/updatermirror/everest_update.yaml";
257+
256258
using (HttpClient wc = new HttpClientWithCompressionSupport()) {
257259
log("Fetching mod updater database URL");
258260
return wc.GetStringAsync("https://everestapi.github.io/modupdater.txt").Result.Trim();

src/modupdater.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function modupdater.updateAllMods(path, notify, mode, callback, showRecap)
2424
return
2525
end
2626

27-
local task = sharp.updateAllMods(path or config.installs[config.install].path, mode == "enabled", config.mirrorPreferences):result()
27+
local task = sharp.updateAllMods(path or config.installs[config.install].path, mode == "enabled", config.mirrorPreferences, config.apiMirror):result()
2828

2929
local alertMessage = alert({
3030
title = mode == "enabled" and "Updating enabled mods" or "Updating all mods",

0 commit comments

Comments
 (0)