Update registry at start of GUI if available_modules is empty #2241
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
If the registry's
available_modules
list is empty while GUI is trying to use it, null reference exceptions can occur.See #1994 and KSP-CKAN/NetKAN#5907 for examples.
Relevant side notes
The GUI already auto-refreshes the
available_modules
list at startup ifconfiguration.RefreshOnStartup
is true.available_modules
is empty by default when first adding a new instance, which we handle by settingconfiguration.RefreshOnStartup
to true for such a newly added instance, so the registry will be loaded when we get to that part of the initialization.Changes
Now the GUI performs its registry auto-refresh in one more situation: when
available_modules
is empty. This ensures that we will re-download the registry if we need to.Linkages
Closes #2115. After looking at that pull request, I don't think the approach is workable;
Create
resets the registry completely, which we do not want in this case because information about installed modules and source repositories is lost. And it doesn't solve the problem; ifconfiguration.RefreshOnStartup
is false, thenavailable_modules
would stay empty and the app would still crash.