Subject: | write_file() atomic remove temp file on error |
Date: | Mon, 22 Apr 2019 10:32:13 +1000 |
To: | bug-File-Slurp [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
If write_file() atomic gets an error renaming its temp file to the
intended destination then that temp file is left behind. I'd be good to
remove it.
For example, create a file /tmp/other owned by root, then as ordinary
user
use File::Slurp;
write_file('/tmp/other', {atomic => 1}, "hello");
=>
leaves its /tmp/tempXXXXXX
A sticky-bit directory like /tmp should be the most common case where
you can get as far as creating the temp but then can't rename to the
target.