Include invalid instances in KSPManager #2230
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.
Problems
If a KSP instance that CKAN knows about is removed manually (i.e., the user deletes the folder), an error message is printed at startup:
But it's impossible to remove it from the list of known installs, because it's not added to the list that is manipulated to make that happen. However, if the user adds another instance, then any currently invalid instances are automatically removed.
None of this is particularly desirable. It should always be possible for the user to remove any instance, but no instance should be removed without the user choosing it.
Changes
Now invalid instances are added to the list of known instances at startup; they appear in the instance selection list in Cmdline, ConsoleUI, and GUI. But if the user tries to use an invalid instance or set it as default, an error message appears indicating that the install is not valid.
This is achieved by defining a new
CKAN.KSP.Valid
property, which guardsCKAN.KSP.CkanDir()
and a few other spots. IfValid
isfalse
when we need it to betrue
to perform an operation, thenNotKSPDirKraken
is thrown and (hopefully) caught by the appropriate UI component. An invalid instance also has a nullVersion
property, because you need a valid instance to get the version, so we have to handle that in the instance listing code now.Linkages
This is the replacement for #2214. (It's actually attempt #3. With any luck, no one will ever see attempt #2, which involved defining a
Tuple<string, string, KSP>
type and convertingKSPManager.Instances
to return it. Allowing KSP objects to be invalid is much more straightforward and less ugly.)Fixes #896.
Fixes #1836.
Fixes #1859.
Merry Christmas, Happy Hannukah, and Happy New Year!