Upgrade AD mods with mismatched version in filename #3287
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.
Problem
If you manually install a version of ModuleManager different from the one CKAN would install for you (e.g., I install MM 4.1.0 but CKAN knows that 4.1.4 is current), trying to convert it to CKAN control by upgrading as per #3043 fails with this error:
Cause
We created that warning to catch cases where the manual install is incorrect, as it says. But the logic of the check is too strict; for a smooth automatic upgrade, we require that the old and new file names match exactly. That won't be the case for some valid manual installs for a mod like ModuleManager, because it puts its version in the file name, and there are multiple different ModuleManager versions compatible with a given KSP version.
Changes
Now we still try to catch bad manual installs, but we no longer require an exact file name match; instead, we just require:
.dll
(case insensitive)This will still complain if the folders don't match, but will now allow different ModuleManager DLLs to replace one another
Now we delete a manually installed DLL we're replacing as part of the install/upgrade transaction (previously would have happened in
DeleteConflictingFiles
before, but only because the file names had to match exactly, which we no longer require)Side changes:
string.EndsWith
because that's probably simpler and fasterRegistry.RegisterDll
now no longer uses a hard coded "GameData" prefix but instead checks the game's primary mod directory for multi-game supportCreateTransactionScope
for deleting overwritten files in Prompt user to overwrite manually installed files #3043, because one is already created in calling code, so that's gone nowFixes #3221.