Skip to content

Commit

Permalink
Pass force=true option to rename in case of loading failure in compil…
Browse files Browse the repository at this point in the history
…ecache (#36638)

This seems to be  affecting Windows systems in particular

(cherry picked from commit 353e129)
  • Loading branch information
musm authored and KristofferC committed Aug 3, 2020
1 parent 45a0c77 commit 04779cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -890,12 +890,11 @@ function unlink(p::AbstractString)
end

# For move command
function rename(src::AbstractString, dst::AbstractString)
function rename(src::AbstractString, dst::AbstractString; force::Bool=false)
err = ccall(:jl_fs_rename, Int32, (Cstring, Cstring), src, dst)
# on error, default to cp && rm
if err < 0
# force: is already done in the mv function
cp(src, dst; force=false, follow_symlinks=false)
cp(src, dst; force=force, follow_symlinks=false)
rm(src; recursive=true)
end
nothing
Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ function compilecache(pkg::PkgId, path::String)
chmod(tmppath, filemode(path) & 0o777)

# this is atomic according to POSIX:
rename(tmppath, cachefile)
rename(tmppath, cachefile; force=true)
return cachefile
end
finally
Expand Down

0 comments on commit 04779cb

Please sign in to comment.