Skip to content

Commit

Permalink
temp cleanup: GC before trying to delete files
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Aug 11, 2019
1 parent 4f2b64a commit 6bade90
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,28 @@ function temp_cleanup_later(path::AbstractString; asap::Bool=false)
end

function temp_cleanup_purge()
need_gc = Sys.iswindows()
for (path, asap) in TEMP_CLEANUP
asap && rm(path, recursive=true, force=true)
if asap && ispath(path)
if need_gc
GC.gc()
need_gc = false
end
rm(path, recursive=true, force=true)
end
!ispath(path) && delete!(TEMP_CLEANUP, path)
end
end

function temp_cleanup_atexit()
need_gc = Sys.iswindows()
for path in keys(TEMP_CLEANUP)
if ispath(path)
if need_gc
GC.gc()
need_gc = false
end
end
rm(path, recursive=true, force=true)
end
end
Expand Down

0 comments on commit 6bade90

Please sign in to comment.