Skip to content

Commit 6b37c5a

Browse files
move to fixed temp dir. Add debug log
1 parent c79f4b8 commit 6b37c5a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

base/file.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
281281
if err.code==Base.UV_EACCES && endswith(path, ".dll")
282282
# Loaded DLLs cannot be deleted on Windows, even with posix delete mode
283283
# but they can be moved. So move out to allow the dir to be deleted
284-
# and DLL deleted via the temp dir cleanup on next reboot
285-
mv(path, tempname() * "_" * basename(path))
284+
# TODO: Add a mechanism to delete these moved files after dlclose or process exit
285+
dir = mkpath(joinpath(tempdir(), "julia_delayed_deletes"))
286+
temp_path = tempname(dir, cleanup = false) * "_" * basename(path)
287+
@debug "Could not delete DLL most likely because it is loaded, moving to tempdir" path temp_path
288+
mv(path, temp_path)
286289
end
287290
end
288291
end

base/loading.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,11 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
29022902
end
29032903

29042904
if cache_objects
2905-
ocachefile = rename_unique_ocachefile(tmppath_so, ocachefile)
2905+
ocachefile_new = rename_unique_ocachefile(tmppath_so, ocachefile)
2906+
if ocachefile_new != ocachefile
2907+
cachefile = cachefile_from_ocachefile(ocachefile_new)
2908+
ocachefile = ocachefile_new
2909+
end
29062910
@static if Sys.isapple()
29072911
run(`$(Linking.dsymutil()) $ocachefile`, Base.DevNull(), Base.DevNull(), Base.DevNull())
29082912
end
@@ -2925,7 +2929,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
29252929
end
29262930
end
29272931

2928-
function rename_unique_ocachefile(tmppath_so::String, ocachefile_orig::String, ocachefile::String = ocachefile_orig, num = 1)
2932+
function rename_unique_ocachefile(tmppath_so::String, ocachefile_orig::String, ocachefile::String = ocachefile_orig, num = 0)
29292933
try
29302934
rename(tmppath_so, ocachefile; force=true)
29312935
catch e

0 commit comments

Comments
 (0)