Commandline: Flatten and refactor getCompatData #1032
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.
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 forSTLCOMPDAT
existing and we would error out if it didn't. This was probably a holdover from the time when this function relied entirely onSTLCOMPDAT
to parse symlinks. We no longer do this. Instead, this check now wraps our symlink check. So we only checkSTLCOMPDAT
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 inSTLCOMPDAT
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 casefind
gives us unexpected results if-d
is not a valid directory.Apart from that, it's just flattening the logic to remove nesting.