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

Mark auto-install correctly when installing from .ckan file #2793

Merged
merged 1 commit into from
Jun 22, 2019

Conversation

HebaruSan
Copy link
Member

Problem

If you install a module from a .ckan file, its dependencies will be marked as manually installed instead of auto-installed (see #2753).

Cause

When installing from the mod list, we use ComputeChangeSetFromModList to calculate the change set to display, but ComputeUserChangeSet generates the change set to install, so ModuleInstaller.InstallList can determine which modules were selected by the user:

full_change_set = await mainModList.ComputeChangeSetFromModList(registry, user_change_set, module_installer, CurrentInstance.VersionCriteria());

CKAN/GUI/MainChangeset.cs

Lines 140 to 145 in 74ff9af

installWorker.RunWorkerAsync(
new KeyValuePair<List<ModChange>, RelationshipResolverOptions>(
mainModList.ComputeUserChangeSet(RegistryManager.Instance(Main.Instance.CurrentInstance).registry).ToList(),
RelationshipResolver.DependsOnlyOpts()
)
);

However, when installing from a .ckan file, we pass ComputeChangeSetFromModList's change set as if it was selected by the user:

CKAN/GUI/MainInstall.cs

Lines 51 to 68 in 74ff9af

List<ModChange> fullChangeSet = new List<ModChange>(
await mainModList.ComputeChangeSetFromModList(
registry,
initialChangeSet,
ModuleInstaller.GetInstance(CurrentInstance, Manager.Cache, GUI.user),
CurrentInstance.VersionCriteria()
)
);
if (fullChangeSet != null && fullChangeSet.Count > 0)
{
// Resolve the provides relationships in the dependencies
installWorker.RunWorkerAsync(
new KeyValuePair<List<ModChange>, RelationshipResolverOptions>(
fullChangeSet,
install_ops
)
);
}

This makes ModuleInstaller.InstallList think that the user selected them all manually.

Changes

Now we only pass the module from the .ckan file in the change set, so the dependencies can be marked as auto-installed. A few other minor changes are made along the way

  • List instead of HashSet since we need a List in the end anyway
  • The install options are generated by RelationshipResolver.DependsOnlyOpts() instead of RelationshipResolver.DefaultOpts() with modifications after the fact, for consistency with other installation codepaths

Fixes #2792.

@HebaruSan HebaruSan added Bug GUI Issues affecting the interactive GUI Pull request Relationships Issues affecting depends, recommends, etc. labels Jun 22, 2019
Copy link
Member

@DasSkelett DasSkelett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great

@HebaruSan HebaruSan merged commit 91c5bf4 into KSP-CKAN:master Jun 22, 2019
@HebaruSan HebaruSan deleted the fix/from-ckan-auto-inst branch June 25, 2019 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GUI Issues affecting the interactive GUI Pull request Relationships Issues affecting depends, recommends, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Auto-installed dependencies are marked as manually installed when installing from .ckan file
2 participants