Skip to content

Commit

Permalink
add way to disable delayed delete for Pkg.gc() to use
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Feb 26, 2024
1 parent 8b4c9c4 commit c28d3fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,16 @@ Stacktrace:
[...]
```
"""
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allow_delayed_delete::Bool=true)
# allow_delayed_delete is used by Pkg.gc() but is otherwise not part of the public API
if islink(path) || !isdir(path)
try
unlink(path)
catch err
if isa(err, IOError)
force && err.code==Base.UV_ENOENT && return
@static if Sys.iswindows()
if err.code==Base.UV_EACCES && endswith(path, ".dll")
if allow_delayed_delete && err.code==Base.UV_EACCES && endswith(path, ".dll")
# 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
Expand Down

0 comments on commit c28d3fb

Please sign in to comment.