Avoid race conditions with recursive rm (#50842)
If two processes attempt to recursively delete a directory at the same
time, then we can end up in a state where the initial `isdir` is `true`,
but by the time it actually deletes the directory it is already gone.
e.g.
-
https://buildkite.com/clima/climacore-ci/builds/2460#0189d254-76a9-474b-ad25-e5b16440d629/140-142
which is triggered by
https://github.com/cjdoris/PackageExtensionCompat.jl/blob/636eb5a14ddf9134d004c93f598515903af26443/src/PackageExtensionCompat.jl#L59
-
https://buildkite.com/clima/climacore-ci/builds/2457#0189c7fe-8872-40c5-9106-da2e621ff55a/139-150
which is triggered by
https://github.com/JuliaGPU/GPUCompiler.jl/blob/06e670657d7ceebc1845d7c9534a8352c33490de/src/rtlib.jl#L152
I've been conservative and only applied this when `force=true`, but
perhaps it should apply generally?