Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't auto-install recommendations when auditing recommendations #2606

Merged
merged 2 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,13 +1012,7 @@ public void AddRemove(IEnumerable<CkanModule> add = null, IEnumerable<string> re
/// </summary>
public void Upgrade(IEnumerable<string> 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);
}

Expand Down
19 changes: 15 additions & 4 deletions Core/Relationships/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,25 @@ public RelationshipResolver(IEnumerable<CkanModule> 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;
/// <summary>
/// Options to install without recommendations.
/// </summary>
public static RelationshipResolverOptions DependsOnlyOpts()
{
return new RelationshipResolverOptions
{
with_recommends = false,
with_suggests = false,
with_all_suggests = false
};
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
4 changes: 1 addition & 3 deletions GUI/MainChangeset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<ModChange>, RelationshipResolverOptions>(
mainModList.ComputeUserChangeSet().ToList(),
install_ops
RelationshipResolver.DependsOnlyOpts()
)
);
}
Expand Down
10 changes: 3 additions & 7 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,6 @@ public async Task<IEnumerable<ModChange>> ComputeChangeSetFromModList(
{
var modules_to_install = new HashSet<CkanModule>();
var modules_to_remove = new HashSet<CkanModule>();
var options = new RelationshipResolverOptions
{
without_toomanyprovides_kraken = false,
with_recommends = false
};

foreach (var change in changeSet)
{
Expand Down Expand Up @@ -610,7 +605,8 @@ public async Task<IEnumerable<ModChange>> ComputeChangeSetFromModList(
new RelationshipResolver(
modules_to_install,
null,
options, registry, version);
RelationshipResolver.DependsOnlyOpts(),
registry, version);
handled_all_too_many_provides = true;
continue;
}
Expand Down Expand Up @@ -642,7 +638,7 @@ public async Task<IEnumerable<ModChange>> 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))));
Expand Down
11 changes: 2 additions & 9 deletions GUI/MainRecommendations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,7 @@ HashSet<CkanModule> 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<CkanModule>() { kvp.Key }).ToList()
)).ToDictionary(
kvp => kvp.Key,
Expand Down Expand Up @@ -336,7 +329,7 @@ private void AuditRecommendations(IRegistryQuerier registry, KspVersionCriteria
GUIModChangeType.Install,
null
)).ToList(),
RelationshipResolver.DefaultOpts()
RelationshipResolver.DependsOnlyOpts()
)
);
}
Expand Down