diff --git a/base/file.jl b/base/file.jl index bb5a203a0e554..66640a20a39a7 100644 --- a/base/file.jl +++ b/base/file.jl @@ -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 diff --git a/base/loading.jl b/base/loading.jl index 4b1b15074cff1..f63bb6bfefaf3 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -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