-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use libuv for tempdir function #31434
Conversation
Is this something we care about? |
Yes, but too late for 1.2. |
@stevengj I addressed your feedback, let me know if these changes now have your approval. Thanks for the review. I also think GetTempPathW could probably just be implemented in Julia, without too much difficulty. Probably best for another PR, however.
|
If we want to go that route, we could switch to just using |
Any reason not to go the libuv route? Seems simpler, then custom casing Windows. |
I was testing
NVM: |
Ok I updated the code and this is now ready for a final review. Last commit handles the UV_ENOBUFS case with tests. I think this is now good to merge. |
8b354e2
to
8af140f
Compare
test/file.jl
Outdated
|
||
var = Sys.iswindows() ? "TMP" : "TMPDIR" | ||
PATH_PREFIX = Sys.iswindows() ? "C:\\" : "/tmp/" | ||
MAX_PATH = (Sys.iswindows() ? 251 : 1024) - length(PATH_PREFIX) - 1 # null-termination character |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference I'm pretty sure there's a bug in the libuv function that hits an edge case that shouldn't happen, which is why the test here is for 251 chars and does not test longer paths.
The edge case occurs on windows when the TMP
variable has 260 chars
hitting this branch I believe https://github.com/libuv/libuv/blob/c4e9657d59723a6273ce68bda935680e1b3596c5/src/win/util.c#L1186
Before merging let me push an update to account for the latest changes on master |
good to merge? |
Fixes the Windows tempdir function returning a path with the trailing slash.
Test failures are unrelated, due to downloads |
@vtjnash can you sign off if this looks good to you? FYI the |
@@ -481,9 +497,6 @@ function tempname() | |||
return s | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to use tempdir()
for d
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will make these changes in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm. feel free to merge.
Obtain the path of a temporary directory (possibly shared with other processes). | ||
""" | ||
tempdir() | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the tempname
doc string below, it might be clearer to add, "This can lead to security holes." and recommend opening the file with O_EXCL
, if this is a concern (in addition to the suggestion to use mktemp
).
Aside: the windows implementation of mktemp
appears to be wrong because it fails to heed this warning.
Someone with merge powers want to take care of this 😉 |
Use libuv's implementation for
tempdir
for both linux and windows. This fixes the inconsistency between the windows and linux version, where the windows version does not currently include a trailing slash when callingtempdir
compared to the linux implementation.