Fix crash on invalid portable or Steam folder #2506
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.
Background
A game folder needs a few things to be considered valid by CKAN:
Without these, CKAN can't do its job, so it looks for other game folders or gives up and asks the user to specify one. (Or at least that's how it's supposed to work.)
Problem
If you have KSP installed in your Steam library, and you delete the readme.txt, buildID64.txt, and buildid.txt files, GUI should show the Select KSP Install window to let you specify a valid game folder, but instead it throws this exception:
Similarly, the same problem can happen if you run
ckan.exe
from a folder that also has aGameData
subfolder but not a full copy of KSP.Cause
That exception means we've loaded and tried to use an invalid game folder; we should be skipping it instead. We check whether a game folder is valid earlier if it's loaded from the registry, but not if it's being auto-added because
KSP.FindGameDir
found it in a Steam library. In effect the Steam library logic skips some of the folder validation.Similarly, the "portable" instance logic also skips the same validation.
Changes
Now
FindAndRegisterDefaultInstance
won't add or return invalid instances, and an invalid "portable" instance will be skipped.This should mean that GUI will pop up the Select KSP Install window, as intended.
Fixes #2504.