Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes
Browse files Browse the repository at this point in the history
IanButterworth committed Feb 26, 2024
1 parent b07d1e1 commit 8b4c9c4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions base/file.jl
Original file line number Diff line number Diff line change
@@ -249,6 +249,10 @@ function mkpath(path::AbstractString; mode::Integer = 0o777)
path
end

# Files that were requested to be deleted but can't be by the current process
# i.e. loaded DLLs on Windows
delayed_delete_dir() = joinpath(tempdir(), "julia_delayed_deletes")

"""
rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
@@ -282,25 +286,28 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
# Loaded DLLs cannot be deleted on Windows, even with posix delete mode
# but they can be moved. So move out to allow the dir to be deleted
# TODO: Add a mechanism to delete these moved files after dlclose or process exit
dir = mkpath(joinpath(tempdir(), "julia_delayed_deletes"))
dir = mkpath(delayed_delete_dir())
temp_path = tempname(dir, cleanup = false) * "_" * basename(path)
@debug "Could not delete DLL most likely because it is loaded, moving to tempdir" path temp_path
mv(path, temp_path)
return
end
end
end
rethrow()
end
else
if recursive
for p in readdir(path)
try
rm(joinpath(path, p), force=force, recursive=true)
catch err
if !(isa(err, IOError) && err.code==Base.UV_EACCES)
rethrow(err)
try
for p in readdir(path)
try
rm(joinpath(path, p), force=force, recursive=true)
catch err
(isa(err, IOError) && err.code==Base.UV_EACCES) || rethrow()
end
end
catch err
(isa(err, IOError) && err.code==Base.UV_EACCES) || rethrow()
end
end
req = Libc.malloc(_sizeof_uv_fs)

0 comments on commit 8b4c9c4

Please sign in to comment.