public void Update(IList <string> mirrors = null) { if (!File.Exists(_versionCachePath) && mirrors == null) { throw new Exception($"Aurora version cache not found at {_versionCachePath} and no mirrors provided"); } if (File.Exists(_versionCachePath)) { UpdateKnownVersionsFromCache(); } if (mirrors != null) { UpdateKnownAuroraVersionsFromMirrors(mirrors); } var checksum = GetChecksum(File.ReadAllBytes(Path.Combine(Program.AuroraLoaderExecutableDirectory, "Clean", "aurora.exe"))); Log.Debug($"Identified checksum {checksum}"); try { CurrentAuroraVersion = AuroraVersions.First(v => v.Checksum.Equals(checksum)); } catch (Exception e) { Log.Error($"Couldn't find Aurora version associated with checksum {checksum}", e); CurrentAuroraVersion = new AuroraVersion(SemVersion.Parse("1.0.0"), checksum); } Log.Debug($"Running Aurora {CurrentAuroraVersion.Version}"); }
public void Update(AuroraVersion version, bool updateRemote = false, bool updateCache = false) { Log.Debug($"Updating mod registry, updateRemote={updateRemote} updateCache={updateCache}"); var mods = GetLocalMods(); IList <Mod> remote = new List <Mod>(); if (updateRemote) { remote = GetModsFromMirrors(); } foreach (var remoteMod in remote) { var existingMod = mods.SingleOrDefault(mod => mod.Name == remoteMod.Name); if (existingMod != null) { var updatedDownloadList = existingMod.Downloads.ToList(); updatedDownloadList.AddRange(remoteMod.Downloads.Where(nd => !existingMod.Downloads.Any(ed => ed.Version == nd.Version))); remoteMod.Downloads = updatedDownloadList; mods.Remove(existingMod); mods.Add(remoteMod); } else { mods.Add(remoteMod); } } foreach (var mod in mods.ToList()) { mod.Downloads.RemoveAll(d => !version.CompatibleWith(d.TargetAuroraVersion)); if (mod.Downloads.Count == 0) { mods.Remove(mod); } } Mods = mods; if (updateRemote && updateCache) { foreach (var mod in Mods.Where(mod => mod.Installed)) { mod.UpdateCache(); } } else if (updateCache && !updateRemote) { throw new ArgumentException("Updating cache without updating remote does nothing"); } }
public void SetUp() { installationPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "AuroraLoaderInstallationTest"); Directory.CreateDirectory(installationPath); auroraVersion = new AuroraVersion(SemVersion.Parse(auroraVersionString), checksum); defaultModVersion = new ModVersion() { Mod = new Mod() { Name = "mod" } }; using (File.Create(Path.Combine(installationPath, "Aurora.exe"))); using (File.Create(Path.Combine(installationPath, "AuroraDB.db"))); }
public GameInstallation(AuroraVersion version, string installationPath) { InstalledVersion = version; InstallationPath = installationPath; }
public bool WorksForVersion(AuroraVersion version) { // TODO Needs to understand wildcarded versions return(TargetAuroraVersion.WorksForVersion(version.Version)); }
public bool CanBeUpdated(AuroraVersion auroraVersion) => LatestVersion != null && LatestInstalledVersion != null && LatestInstalledVersionCompatibleWith(auroraVersion).Version.CompareByPrecedence(LatestVersionCompatibleWith(auroraVersion).Version) < 0;
public ModVersion LatestInstalledVersionCompatibleWith(AuroraVersion auroraVersion) => Downloads.OrderByDescending(v => v.Version) .Where(v => v.Downloaded && auroraVersion.CompatibleWith(v.TargetAuroraVersion)) .FirstOrDefault();