-
-
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
Fix mkpath error handling #36126
Fix mkpath error handling #36126
Conversation
The error thrown by `mkdir` when the directory already exists was changed in #33422.
@@ -228,7 +228,7 @@ function mkpath(path::AbstractString; mode::Integer = 0o777) | |||
catch err | |||
# If there is a problem with making the directory, but the directory | |||
# does in fact exist, then ignore the error. Else re-throw it. | |||
if !isa(err, SystemError) || !isdir(path) | |||
if !isa(err, IOError) || !isdir(path) |
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.
Would it be better to do?
if !isa(err, IOError) || !isdir(path) | |
if !(isa(err, IOError) && err.code == UV_EEXIST) |
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.
I assume it doesn't matter because of the isdir
test?
julia> mkpath("/nonexistant")
ERROR: IOError: mkdir: permission denied (EACCES)
Stacktrace:
[1] uv_error at ./libuv.jl:97 [inlined]
[2] mkdir(::String; mode::UInt16) at ./file.jl:177
[3] mkpath(::String; mode::UInt16) at ./file.jl:227
[4] mkpath(::String) at ./file.jl:222
[5] top-level scope at REPL[3]:1
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.
Arguably in that case you would want the error to be propagated?
The error thrown by `mkdir` when the directory already exists was changed in JuliaLang#33422.
The error thrown by
mkdir
when the directory already exists was changed in #33422.Unfortunately, this is hard to test, though we came across it on a cluster with a shared file system.
cc: @jakebolewski @kpamnany