public ModDownload CheckModularVersion(ModInfo mod, string folder, List <ModManifestEntry> localManifest, UpdaterWebClient client, List <string> errors) { if (!mod.UpdateUrl.StartsWith("http://", StringComparison.InvariantCulture) && !mod.UpdateUrl.StartsWith("https://", StringComparison.InvariantCulture)) { mod.UpdateUrl = "http://" + mod.UpdateUrl; } if (!mod.UpdateUrl.EndsWith("/", StringComparison.InvariantCulture)) { mod.UpdateUrl += "/"; } var url = new Uri(mod.UpdateUrl); url = new Uri(url, "mod.ini"); ModInfo remoteInfo; try { Dictionary <string, Dictionary <string, string> > dict = IniFile.IniFile.Load(client.OpenRead(url)); remoteInfo = IniSerializer.Deserialize <ModInfo>(dict); } catch (Exception ex) { errors.Add($"[{mod.Name}] Error pulling mod.ini from \"{mod.UpdateUrl}\": {ex.Message}"); return(null); } if (!ForceUpdate && remoteInfo.Version == mod.Version) { return(null); } string manString; try { manString = client.DownloadString(new Uri(new Uri(mod.UpdateUrl), "mod.manifest")); } catch (Exception ex) { errors.Add($"[{mod.Name}] Error pulling mod.manifest from \"{mod.UpdateUrl}\": {ex.Message}"); return(null); } List <ModManifestEntry> remoteManifest; try { remoteManifest = ModManifest.FromString(manString); } catch (Exception ex) { errors.Add($"[{mod.Name}] Error parsing remote manifest from \"{mod.UpdateUrl}\": {ex.Message}"); return(null); } List <ModManifestDiff> diff = ModManifestGenerator.Diff(remoteManifest, localManifest); if (diff.Count < 1 || diff.All(x => x.State == ModManifestState.Unchanged)) { return(null); } string changes; if (!string.IsNullOrEmpty(mod.ChangelogUrl)) { try { changes = client.DownloadString(new Uri(mod.ChangelogUrl)); } catch (Exception ex) { changes = ex.Message; } } else { try { changes = client.DownloadString(new Uri(new Uri(mod.UpdateUrl), "changelog.txt")); } catch { // ignored changes = string.Empty; } } if (!string.IsNullOrEmpty(changes)) { changes = Regex.Replace(changes, "(?<!\r)\n", "\r\n"); } return(new ModDownload(mod, Path.Combine("mods", folder), mod.UpdateUrl, changes, diff)); }