Skip to content
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

[Bug] Symlinks to Directories in Mods Dir Aren't Traversed #3417

Closed
rehashedsalt opened this issue Nov 19, 2023 · 0 comments · Fixed by #3418
Closed

[Bug] Symlinks to Directories in Mods Dir Aren't Traversed #3417

rehashedsalt opened this issue Nov 19, 2023 · 0 comments · Fixed by #3418

Comments

@rehashedsalt
Copy link
Contributor

When Ship loads OTRs out of ./mods, the following behavior is observed:

  • Files with the file extension .otr are loaded
  • Directories that contain .otr files are traversed and .otr files within are loaded
  • Symbolic links to .otr files are loaded

Based on this behavior one would expect symbolic links to directories to be traversed for .otr files. This is not the case -- Ship does not traverse symlinks in ./mods.

Errant code is here: https://github.com/HarbourMasters/Shipwright/blob/8dbf738128d0c9d2a0e6c7ece40fa4659edafc1c/soh/soh/OTRGlobals.cpp#L258C34-L258C79

    if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) {
        if (std::filesystem::is_directory(patchesPath)) {
            for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) {
                if (StringHelper::IEquals(p.path().extension().string(), ".otr")) {
                    OTRFiles.push_back(p.path().generic_string());
                }
            }
        }
    }

According to upstream documentation, std::filesystem::recursive_directory_iterator just needs an option specified at construction time telling it it's allowed to traverse symlinks.

Fixing this bug would allow for more versatile mod management and consistent behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant