Skip to content

Commit 76ec9d6

Browse files
hof mktemp/dir: don't error if temp path is already gone (#33091)
1 parent 8093a7c commit 76ec9d6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ New library functions
2727
Standard library changes
2828
------------------------
2929

30+
* The methods of `mktemp` and `mktempdir` which take a function body to pass temporary paths to no longer throw errors if the path is already deleted when the function body returns ([#33091]).
3031

3132
#### Libdl
3233

base/file.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ function mktemp(fn::Function, parent::AbstractString=tempdir())
612612
finally
613613
try
614614
close(tmp_io)
615-
rm(tmp_path)
615+
ispath(tmp_path) && rm(tmp_path)
616616
catch ex
617617
@error "mktemp cleanup" _group=:file exception=(ex, catch_backtrace())
618618
# might be possible to remove later
@@ -634,7 +634,7 @@ function mktempdir(fn::Function, parent::AbstractString=tempdir();
634634
fn(tmpdir)
635635
finally
636636
try
637-
rm(tmpdir, recursive=true)
637+
ispath(tmpdir) && rm(tmpdir, recursive=true)
638638
catch ex
639639
@error "mktempdir cleanup" _group=:file exception=(ex, catch_backtrace())
640640
# might be possible to remove later

0 commit comments

Comments
 (0)