Better partial upgrade checking#4669
Merged
Merged
Conversation
Coverage Report for CI Build 27596207600Coverage increased (+0.08%) to 87.801%Details
Uncovered Changes
Coverage Regressions4 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
af5dbc8 to
2d1c025
Compare
a2df7a4 to
7f64f80
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Causes
In
Hyperion_21's case, both MechJeb2-dev and RasterPropMonitor had old versions installed, and RasterPropMonitor's latest version had a conflict with MechJeb, which is provided by all versions of MechJeb2-dev, so upgrading RasterPropMonitor wasn't allowed. However, that potential update still ended up in the "context of upgrading everything else" against which MechJeb2-dev was checked, which blocked that mod's upgrade as well.RepositoryDataManager.GetDownloadCountused.OfType<int>().FirstOrDefault()to handle null values, but thedefaultofintis0, so the function could never returnnulleven thought it was designed for that. But even without that,GetValueOrDefaultalso returns0for a missing value when the dict's value type isint!GUIMod.DownloadSizeandGUIMod.InstallSizewere set to "N/A" if the underlying values were0ModuleInstaller.CanInstall, which is responsible for checking which supporting mods are installable, lacked atoRemoveparam to handle mods being removed. Instead, it decided to pretend that all mods were being removed, so installed mods' conflicts would be ignored.Motivations
This rogue repository has since been deleted, but conditions are arguably ripe for this to happen again at some point.
Changes
HasUpdateagainst the accumulated set of updates, and if it returns true, it first adds that update to the set and continues checking the rest of the mods. Then, regardless of whatHasUpdatereturned, it tries a group with the currently installed module instead, to catch cases where another mod prevents this one from updating. Each time it has a complete group of choices, it usesRelationshipResolverto make sure it's valid.Not only is this more correct, I think it may also be faster based on timings of test runs (it does incur fewer
HasUpdatecalls on average).A test is added to exercise Hyperion_21's use case, which passes on the new code and fails on the old code.
GetDownloadCountusesTryGetValueto get the values and an explicit null check to avoid ever accidentally returningdefault(int), so the grid cells will be blank instead of 0 for unknown counts.toRemoveparam ofModuleInstaller.CanInstall, so the "Supported by" list will be more accurate.RepositoryListand used to display an error when the user tries to add a known-bad repo: