-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check grandparent+ directories for find and find_regexp #2120
Conversation
That looks great. Any chance you could put together a test case to make sure this doesn't get broken in future? |
Good idea. I don't know much about creating tests, though. How do I run the current tests locally? I thought I saw them at the end of the UPDATE: Looks like it's
Am I missing something? UPDATE II: If I skip that test with UPDATE III: Oops,
2.6.4.0 is the newest version for the most recent Ubuntu release, but I saw a rumor that it's also available via NuGet. Wish me luck! UPDATE IV: I finally succeeded in running the current tests (and my new one as well, though the test data is not complete yet). Added a section to the wiki to hopefully make it easier for the next person (and myself, next time). |
You can run the tests with |
Thanks, that's much simpler! Wiki updated. |
ZIP files can contain entries for directories, but it's optional. Currently, CKAN behaves differently depending on whether these entries are present, which is probably bad since it may not be controllable by or even apparent to the user.
find
andfind_regexp
currently loop through each entry in the ZIP and check whether they match against the search pattern. If file matching is turned on, the names of file entries are checked, otherwise their immediate parent folders are checked. If there are multiple matches, the shortest one is used.This algorithm only works in two cases:
It fails for an important third case:
For example, take a look at PlanetCerillion (many files omitted for brevity):
https://github.com/KSP-CKAN/NetKAN/blob/f6a054d20ca962da0f11bb5e2abf47616996b3a1/NetKAN/PlanetCerillion.netkan#L3-L7
The
find
clause is trying to find thePlanet_Cerillion
directory, but it is not present as a directory entry, and all the files are contained within sub-subfolders rather than directly underPlanet_Cerillion
. This causes "Could not find Planet_Cerillion entry in zipfile to install".With the attached code changes, the algorithm will check all grandparent, great-grandparent, etc. directories. This fixes the Planet_Cerillion case above, as well as the problem found in KSP-CKAN/NetKAN#5841 and probably others.