Protect upgradeable mods from being displayed as uninstalled #3944
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
The fix for installed mods showing up as not installed from #3934 was incomplete; it addressed installed mods that can't be upgraded, but the problem can still happen for installed mods that are upgradeable. If such a mod happens to load as uninstalled and you try to upgrade it, an exception is thrown:
Reported by @jan-bures on Discord.
Cause
I used
.Except()
to filter installed mods out of the compatible and incompatible lists, but that only works when theirCkanModule.version
properties are the same. For an upgradeable mod, its version in the compatible list is newer than the installed verson, so.Except()
doesn't filter it out, and we once again have a race condition.Changes
.ExceptBy()
is not available until .NET 6+).new type[0]
expressions toArray.Empty<type>()
because this was recommended by VSCode at some point.I'll self-review this since it's small and familiar, and so we can consider a quick hotfix release before KSP2 0.2.0.0 comes out.