linuxgurugamer / KSPAddonVersionChecker

KSP-AVC in-game plugin.
15 stars 14 forks source link

Handle duplicative dll paths #13

Closed HebaruSan closed 6 years ago

HebaruSan commented 6 years ago

Motivation

https://github.com/KSP-CKAN/NetKAN/issues/1455#issuecomment-217134778

If a copy of miniavc.dll exists in both the GameData base folder and any subfolder then all dialogs surfaced by the mod are surfaced twice and that is annoying AF if you have a couple hundred mods installed.

This pull request aims to fix that.

Cause

The scenario described above can be generalized to any situation in which two copies of MiniAVC.dll are located in directories which are in an ancestor/descendant relationship. E.g.:

Or even something like:

In those cases, this code will find version files in the nested subfolder multiple times and add them to the list of addons to check:

https://github.com/linuxgurugamer/KSPAddonVersionChecker/blob/0caed8a8baffbd78885d1f8a701a803b2ba20463/MiniAVC/AddonLibrary.cs#L90-L100

Later this results in multiple popups if there are incompatibilities or updates.

Changes

Now we build a temporary Dictionary that tracks version files and their associated settings. If we find the same version file more than once, we don't add it multiple times; instead we compare the associated settings files and choose the one that is closest to that version file. Once we've checked all the files, we collapse the Dictionary to a list of Addons, as before.

This is what I was trying to compile on the mod adoption tutorial thread. I have not been able to get the build working, so there may be syntax errors here; just let me know and I'll fix them.

linuxgurugamer commented 6 years ago

Merged into a branch, will test first

linuxgurugamer commented 6 years ago

Did you consider, instead of adding all this, to modify it to only look a .version files in the same directory it is in? That is the original intention of it

HebaruSan commented 6 years ago

I assume that would break existing usages. E.g.:

HebaruSan commented 6 years ago

And it doesn't look like that's the original intention:

This plugin checks inside its current directory and all contained directories for version files.

  • If your add-on contains multiple version files, place it at the lowest directory level which will cover all the version files, but do not place it in GameData.

The changelog doesn't mention this being added later; looks like "all contained directories" was part of the intention all along.

linuxgurugamer commented 6 years ago

I see, you are correct.

linuxgurugamer commented 6 years ago

I've been testing this. This works for the DLL, but it still shows multiple entries if there are multiple copies of the .version file. Still a great improvement