private void UpdateRepo(object sender, DoWorkEventArgs e) { try { AddStatusMessage("Updating repositories..."); // Note the current mods' compatibility for the NewlyCompatible filter KspVersionCriteria versionCriteria = CurrentInstance.VersionCriteria(); IRegistryQuerier registry = RegistryManager.Instance(CurrentInstance).registry; Dictionary <string, bool> oldModules = registry.Available(versionCriteria) .ToDictionary(m => m.identifier, m => false); registry.Incompatible(versionCriteria) .Where(m => !oldModules.ContainsKey(m.identifier)) .ToList() .ForEach(m => oldModules.Add(m.identifier, true)); RepoUpdateResult result = Repo.UpdateAllRepositories( RegistryManager.Instance(CurrentInstance), CurrentInstance, Manager.Cache, GUI.user); e.Result = new KeyValuePair <RepoUpdateResult, Dictionary <string, bool> >( result, oldModules); } catch (UriFormatException ex) { errorDialog.ShowErrorDialog(ex.Message); } catch (MissingCertificateKraken ex) { errorDialog.ShowErrorDialog(ex.ToString()); } catch (Exception ex) { errorDialog.ShowErrorDialog("Failed to connect to repository. Exception: " + ex.Message); } }
private void UpdateRepo(object sender, DoWorkEventArgs e) { try { AddStatusMessage(Properties.Resources.MainRepoScanning); log.Debug("Scanning before repo update"); bool scanChanged = CurrentInstance.Scan(); AddStatusMessage(Properties.Resources.MainRepoUpdating); // Note the current mods' compatibility for the NewlyCompatible filter GameVersionCriteria versionCriteria = CurrentInstance.VersionCriteria(); IRegistryQuerier registry = RegistryManager.Instance(CurrentInstance).registry; Dictionary <string, bool> oldModules = registry.CompatibleModules(versionCriteria) .ToDictionary(m => m.identifier, m => false); registry.IncompatibleModules(versionCriteria) .Where(m => !oldModules.ContainsKey(m.identifier)) .ToList() .ForEach(m => oldModules.Add(m.identifier, true)); RepoUpdateResult result = Repo.UpdateAllRepositories( RegistryManager.Instance(CurrentInstance), CurrentInstance, Manager.Cache, currentUser); if (result == RepoUpdateResult.NoChanges && scanChanged) { result = RepoUpdateResult.Updated; } e.Result = new KeyValuePair <RepoUpdateResult, Dictionary <string, bool> >( result, oldModules); } catch (UriFormatException ex) { errorDialog.ShowErrorDialog(ex.Message); } catch (MissingCertificateKraken ex) { errorDialog.ShowErrorDialog(ex.ToString()); } catch (ReinstallModuleKraken) { // Bypass the generic error dialog so the Post can handle this throw; } catch (Exception ex) { errorDialog.ShowErrorDialog(string.Format(Properties.Resources.MainRepoFailedToConnect, ex.Message)); } }