Calls saveRDS
in a fault-tolerant manner, such
that if the save fails, the existing file will not be overwritten. This is
done with the following scheme:
Call saveRDS
to save the file to via_filename
.
If that succeeds, call file.rename
to rename
the new file to overwrite filename
.
The underlying implementation of file.rename
uses the POSIX function
rename
, which has the guarantee that it either succeeds or leaves
the destination file untouched (subject to hardware limitations). Therefore,
this function also either succeeds, or leaves filename
untouched. In
reality, this guarantee is almost certainly dependent on the operating
system, the file system, and a host of other factors. Still, even if the
guarantee is not fully satisfied, renaming the file ought to be faster and
therefore a system failure during the rename is less likely than during
saveRDS
.
1 | safe_saveRDS(object, filename, via_filename, ...)
|
object |
R object to serialize. |
filename |
Destination filename. Unlike
|
via_filename |
Filename to save the file to before the rename step.
This should probably be on the same filesystem as |
... |
Passed to |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.