Skip to content

Commit c28d3fb

Browse files
add way to disable delayed delete for Pkg.gc() to use
1 parent 8b4c9c4 commit c28d3fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

base/file.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,16 @@ Stacktrace:
274274
[...]
275275
```
276276
"""
277-
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
277+
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false, allow_delayed_delete::Bool=true)
278+
# allow_delayed_delete is used by Pkg.gc() but is otherwise not part of the public API
278279
if islink(path) || !isdir(path)
279280
try
280281
unlink(path)
281282
catch err
282283
if isa(err, IOError)
283284
force && err.code==Base.UV_ENOENT && return
284285
@static if Sys.iswindows()
285-
if err.code==Base.UV_EACCES && endswith(path, ".dll")
286+
if allow_delayed_delete && err.code==Base.UV_EACCES && endswith(path, ".dll")
286287
# Loaded DLLs cannot be deleted on Windows, even with posix delete mode
287288
# but they can be moved. So move out to allow the dir to be deleted
288289
# TODO: Add a mechanism to delete these moved files after dlclose or process exit

0 commit comments

Comments
 (0)