From f2d47f7b4b4e0b783a318e9e0c65d42fd548eae3 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 7 Dec 2018 19:13:00 -0600 Subject: [PATCH 1/2] Don't auto-install recommendations when auditing recommendations --- Core/ModuleInstaller.cs | 8 +------- Core/Relationships/RelationshipResolver.cs | 19 +++++++++++++++---- GUI/MainChangeset.cs | 4 +--- GUI/MainModList.cs | 10 +++------- GUI/MainRecommendations.cs | 11 ++--------- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/Core/ModuleInstaller.cs b/Core/ModuleInstaller.cs index f28479d411..3b2048af6b 100644 --- a/Core/ModuleInstaller.cs +++ b/Core/ModuleInstaller.cs @@ -1012,13 +1012,7 @@ public void AddRemove(IEnumerable add = null, IEnumerable re /// public void Upgrade(IEnumerable identifiers, IDownloader netAsyncDownloader, bool enforceConsistency = true) { - var options = new RelationshipResolverOptions(); - - // We do not wish to pull in any suggested or recommended mods. - options.with_recommends = false; - options.with_suggests = false; - - var resolver = new RelationshipResolver(identifiers.ToList(), null, options, registry_manager.registry, ksp.VersionCriteria()); + var resolver = new RelationshipResolver(identifiers.ToList(), null, RelationshipResolver.DependsOnlyOpts(), registry_manager.registry, ksp.VersionCriteria()); Upgrade(resolver.ModList(), netAsyncDownloader, enforceConsistency); } diff --git a/Core/Relationships/RelationshipResolver.cs b/Core/Relationships/RelationshipResolver.cs index c95377b0df..a0063fb24b 100644 --- a/Core/Relationships/RelationshipResolver.cs +++ b/Core/Relationships/RelationshipResolver.cs @@ -191,14 +191,25 @@ public RelationshipResolver(IEnumerable modulesToInstall, IEnumerabl // and the defaults in the class definition should do the right thing. public static RelationshipResolverOptions DefaultOpts() { - var opts = new RelationshipResolverOptions + return new RelationshipResolverOptions { - with_recommends = true, - with_suggests = false, + with_recommends = true, + with_suggests = false, with_all_suggests = false }; + } - return opts; + /// + /// Options to install without recommendations. + /// + public static RelationshipResolverOptions DependsOnlyOpts() + { + return new RelationshipResolverOptions + { + with_recommends = false, + with_suggests = false, + with_all_suggests = false + }; } /// diff --git a/GUI/MainChangeset.cs b/GUI/MainChangeset.cs index e281870d14..754bbd9973 100644 --- a/GUI/MainChangeset.cs +++ b/GUI/MainChangeset.cs @@ -119,15 +119,13 @@ private void ConfirmChangesButton_Click(object sender, EventArgs e) menuStrip1.Enabled = false; RetryCurrentActionButton.Visible = false; - RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts(); - install_ops.with_recommends = false; //Using the changeset passed in can cause issues with versions. // An example is Mechjeb for FAR at 25/06/2015 with a 1.0.2 install. // TODO Work out why this is. installWorker.RunWorkerAsync( new KeyValuePair, RelationshipResolverOptions>( mainModList.ComputeUserChangeSet().ToList(), - install_ops + RelationshipResolver.DependsOnlyOpts() ) ); } diff --git a/GUI/MainModList.cs b/GUI/MainModList.cs index 80c404e514..70290bcfd5 100644 --- a/GUI/MainModList.cs +++ b/GUI/MainModList.cs @@ -572,11 +572,6 @@ public async Task> ComputeChangeSetFromModList( { var modules_to_install = new HashSet(); var modules_to_remove = new HashSet(); - var options = new RelationshipResolverOptions - { - without_toomanyprovides_kraken = false, - with_recommends = false - }; foreach (var change in changeSet) { @@ -610,7 +605,8 @@ public async Task> ComputeChangeSetFromModList( new RelationshipResolver( modules_to_install, null, - options, registry, version); + RelationshipResolver.DependsOnlyOpts(), + registry, version); handled_all_too_many_provides = true; continue; } @@ -642,7 +638,7 @@ public async Task> ComputeChangeSetFromModList( var resolver = new RelationshipResolver( modules_to_install, changeSet.Where(change => change.ChangeType.Equals(GUIModChangeType.Remove)).Select(m => m.Mod.ToModule()), - options, registry, version); + RelationshipResolver.DependsOnlyOpts(), registry, version); changeSet.UnionWith( resolver.ModList() .Select(m => new ModChange(new GUIMod(m, registry, version), GUIModChangeType.Install, resolver.ReasonFor(m)))); diff --git a/GUI/MainRecommendations.cs b/GUI/MainRecommendations.cs index 9c99beeaf0..fcaf9a6694 100644 --- a/GUI/MainRecommendations.cs +++ b/GUI/MainRecommendations.cs @@ -114,14 +114,7 @@ HashSet toInstall { return mods.Where(kvp => CanInstall( registry, versionCriteria, - new RelationshipResolverOptions() - { - with_all_suggests = false, - with_recommends = false, - with_suggests = false, - without_enforce_consistency = false, - without_toomanyprovides_kraken = false - }, + RelationshipResolver.DependsOnlyOpts(), toInstall.ToList().Concat(new List() { kvp.Key }).ToList() )).ToDictionary( kvp => kvp.Key, @@ -336,7 +329,7 @@ private void AuditRecommendations(IRegistryQuerier registry, KspVersionCriteria GUIModChangeType.Install, null )).ToList(), - RelationshipResolver.DefaultOpts() + RelationshipResolver.DependsOnlyOpts() ) ); } From 7208a28610ca3b2531dc04ef796dc624f64aea4b Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 8 Dec 2018 15:14:28 -0600 Subject: [PATCH 2/2] Disable audit recommendations when there's a change set --- GUI/Main.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GUI/Main.cs b/GUI/Main.cs index d0159900d2..97714986ff 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -155,11 +155,13 @@ private void ChangeSetUpdated() UpdateChangesDialog(ChangeSet.ToList(), installWorker); tabController.ShowTab("ChangesetTabPage", 1, false); ApplyToolButton.Enabled = true; + auditRecommendationsMenuItem.Enabled = false; } else { tabController.HideTab("ChangesetTabPage"); ApplyToolButton.Enabled = false; + auditRecommendationsMenuItem.Enabled = true; } }