@@ -675,7 +675,7 @@ impl<F> NamedTempFile<F> {
675
675
/// If this method fails, it will return `self` in the resulting
676
676
/// [`PersistError`].
677
677
///
678
- /// Note: Temporary files cannot be persisted across filesystems. Also
678
+ /// ** Note:** Temporary files cannot be persisted across filesystems. Also
679
679
/// neither the file contents nor the containing directory are
680
680
/// synchronized, so the update may not yet have reached the disk when
681
681
/// `persist` returns.
@@ -723,9 +723,15 @@ impl<F> NamedTempFile<F> {
723
723
/// If a file exists at the target path, fail. If this method fails, it will
724
724
/// return `self` in the resulting PersistError.
725
725
///
726
- /// Note: Temporary files cannot be persisted across filesystems. Also Note:
727
- /// This method is not atomic. It can leave the original link to the
728
- /// temporary file behind.
726
+ /// **Note:** Temporary files cannot be persisted across filesystems.
727
+ ///
728
+ /// **Atomicity:** This method is not guaranteed to be atomic on all platforms, although it will
729
+ /// generally be atomic on Windows and modern Linux filesystems. While it will never overwrite a
730
+ /// file at the target path, it may leave the original link to the temporary file behind leaving
731
+ /// you with two [hard links][] in your filesystem pointing at the same underlying file. This
732
+ /// can happen if either (a) we lack permission to "unlink" the original filename; (b) this
733
+ /// program crashes while persisting the temporary file; or (c) the filesystem is removed,
734
+ /// unmounted, etc. while we're performing this operation.
729
735
///
730
736
/// # Security
731
737
///
@@ -750,6 +756,8 @@ impl<F> NamedTempFile<F> {
750
756
/// writeln!(persisted_file, "Brian was here. Briefly.")?;
751
757
/// # Ok::<(), std::io::Error>(())
752
758
/// ```
759
+ ///
760
+ /// [hardlink]: https://en.wikipedia.org/wiki/Hard_link
753
761
pub fn persist_noclobber < P : AsRef < Path > > ( self , new_path : P ) -> Result < F , PersistError < F > > {
754
762
let NamedTempFile { path, file } = self ;
755
763
match path. persist_noclobber ( new_path) {
0 commit comments