Skip to content

Commit d6b33ea

Browse files
temp_cleanup_purge: default to force=false, make keyword argument (#36161)
This is a potentially useful function for testing but `force=true` is only useful when the process is shutting down, so it should not be the default.
1 parent d31962c commit d6b33ea

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

base/file.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,18 +470,18 @@ function temp_cleanup_later(path::AbstractString; asap::Bool=false)
470470
# still be using the path, don't delete it until process exit
471471
TEMP_CLEANUP[path] = get(TEMP_CLEANUP, path, true) & asap
472472
if length(TEMP_CLEANUP) > TEMP_CLEANUP_MAX[]
473-
temp_cleanup_purge(false)
473+
temp_cleanup_purge()
474474
TEMP_CLEANUP_MAX[] = max(TEMP_CLEANUP_MIN[], 2*length(TEMP_CLEANUP))
475475
end
476476
unlock(TEMP_CLEANUP_LOCK)
477477
return nothing
478478
end
479479

480-
function temp_cleanup_purge(all::Bool=true)
480+
function temp_cleanup_purge(; force::Bool=false)
481481
need_gc = Sys.iswindows()
482482
for (path, asap) in TEMP_CLEANUP
483483
try
484-
if (all || asap) && ispath(path)
484+
if (force || asap) && ispath(path)
485485
need_gc && GC.gc(true)
486486
need_gc = false
487487
rm(path, recursive=true, force=true)

base/initdefs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ end
293293

294294
## atexit: register exit hooks ##
295295

296-
const atexit_hooks = Callable[Filesystem.temp_cleanup_purge]
296+
const atexit_hooks = Callable[
297+
() -> Filesystem.temp_cleanup_purge(force=true)
298+
]
297299

298300
"""
299301
atexit(f)

0 commit comments

Comments
 (0)