Restore uninstallation of dependencies #2579
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
As of #2561, if you try to remove a module that other installed modules depend on, you can't; the Apply button stays disabled and the status bar reports missing dependencies:
Before that pull request, this was allowed and would allow you to remove the module and mods depending on it. This isn't something we should break.
Background
MainModList.ComputeChangeSetFromModList
creates multipleRelationshipResolver
s for different purposes. First it creates one or more in a loop to resolve allprovides
relationships (even if there are noprovides
relationships involved):CKAN/GUI/MainModList.cs
Lines 604 to 616 in 8b791df
After that it find mods with unsatisfied dependencies and queues them up to be removed:
CKAN/GUI/MainModList.cs
Lines 634 to 640 in 8b791df
Then at the end it creates another
RelationshipResolver
to determine the actual change set:CKAN/GUI/MainModList.cs
Lines 642 to 651 in 8b791df
Cause
As of #2561,
RelationshipResolver
has a parameter for modules to uninstall. This allows us to specify a complete change set for evaluation, so that operations that depend on removal for their validity can succeed.When that parameter was added, the
provides
loop ofMainModList.ComputeChangeSetFromModList
was updated to passmodules_to_remove
, but this caused exceptions to be thrown if you were removing a dependency. This loop isn't designed to handle those exceptions, so they propagated out and messed everything up.Changes
Now the loop to resolve
provides
relationships passesnull
instead ofmodules_to_remove
. This will avoid raising exceptions for missing dependencies, and so the rest of the logic can run as expected. Other usages ofRelationshipResolver
still use work as before.Fixes #2578.