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

Commandline: Flatten and refactor getCompatData #1032

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

sonic2kk
Copy link
Owner

Along the lines of #1031 and #1011, but also a slightly more significant refactor.

This PR flattens the structure of getCompatData , making it return early instead of having a bunch of nesting. It also removes an unnecessary codepath. We had some weird check for STLCOMPDAT existing and we would error out if it didn't. This was probably a holdover from the time when this function relied entirely on STLCOMPDAT to parse symlinks. We no longer do this. Instead, this check now wraps our symlink check. So we only check STLCOMPDAT for symlinks if it exists, and if we find a path to the compatdata we're looking for, we return it here and exit early. This makes much more logical sense to me; if we didn't find the path in STLCOMPDAT we were moving on to check for the compatdata in the library folder manually anyway, so there's no need to error out if the STL folder simply doesn't exist (which is almost guaranteed to never be the case as STL verifies its folder structure).

STLCOMPDAT just points to, for example, ~/.config/steamtinkerlaunch/compatdata. It doesn't represent any specific compdatdata, so this check was a pointless check on the STL folder structure. There is no need to error out. Honestly, the -d check is kind of pointless to begin with, but it's for safety in case find gives us unexpected results if -d is not a valid directory.

Apart from that, it's just flattening the logic to remove nesting.

@sonic2kk
Copy link
Owner Author

Needs a rebase and some more testing, but ShellCheck is green.

@sonic2kk
Copy link
Owner Author

Appears to work in testing, can probably rebase and merge.

@sonic2kk sonic2kk force-pushed the flatten-getcompatdata branch from c9d89d3 to 6b1801c Compare January 27, 2024 17:28
@sonic2kk
Copy link
Owner Author

ShellCheck is green still after a rebase and this seems to work fine, can merge.

@sonic2kk sonic2kk merged commit 36100e1 into master Jan 27, 2024
@sonic2kk sonic2kk deleted the flatten-getcompatdata branch January 27, 2024 17:39
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 this pull request may close these issues.

1 participant