-
Notifications
You must be signed in to change notification settings - Fork 1.5k
<filesystem>
: Fix the path
returned when there is an error with temp_directory_path
and simplify the validation logic
#5561
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Lines 4049 to 4052 in 7841cf8
@StephanTLavavej What's the significance of using different categories here? The standard doesn't seem to require it.
|
What Windows error code would we synthesize to indicate "not a directory"? |
If the path points to a symlink but the target does not exist then The File APIs does not seem to strictly distinguish between files and directories in its error codes, and the error codes appear to be unstable. Unless necessary, identifying or conversion should be avoided. |
<filesystem>
Fix the path
returned when there is an error with temp_directory_path
<filesystem>
: Fix the path
returned when there is an error with temp_directory_path
There are a lot of logic changes here, much more than are needed to simply clear the path on error. Can you please update your PR description to explain how the code is changing? This is both for my benefit while reviewing, and for future maintainers/contributors to understand what changed. Edit: Indeed, it looks like these are unrelated behavioral changes. We try to avoid mixing together bugfixes with other behavioral changes (or even cleanups) unless they are inextricably linked. |
<filesystem>
: Fix the path
returned when there is an error with temp_directory_path
<filesystem>
: Fix the path
returned when there is an error with temp_directory_path
and simplify the validation logic
Should I split it into two PRs? |
Yes, please. |
Fix #5557.
In the current implementation,
temp_directory_path
would first useGetTempPath
/GetTempPath2W
to obtain the temp path, then useGetFileAttributesW
to obtain file attributes to verify if it was a directory. If the file is not a directory but is a symlink, the symlink would be opened to verify that the symlink is correct. SinceGetFileAttributesW
internally opens the file and usesGetFileInformationByHandleEx
to obtain file attributes, the current logic contains redundancy. Instead, we should unconditionally open the path obtained byGetTempPath
/GetTempPath2W
, follow symlinks, and verify that it is a directory throughGetFileInformationByHandleEx
.