[Fix] Make checkDiskSpace look at the correct drive again #3654
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.
In my checkDiskSpace refactor (#3440), I used the
root
property of the object returned by Node'spath.parse
, thinking that it'd, logically, give me the root folder (or in other words the mount point) of the disk the path is on. This is not the case on Linux/macOS, it's just simply always/
there.This issue would manifest itself in the wrong disk space info being displayed when installing a game onto a drive other than the primary one.
Resolving this was somewhat tricky. Since this function runs on both macOS and Linux, we can't use commandline tools like
findmnt
to help us here, so I went back to what we did before the refactor: Going up the directory tree and using the first path that exists. This works just fine on Unix, since there will always be a/
path (as opposed to Windows, where entire drive letters can be missing)I've also added a test for these functions now, so this issue can't happen again.
To test this:
Use the following Checklist if you have changed something on the Backend or Frontend: