Skip to main content

seed_target_file

Function seed_target_file 

Source
pub fn seed_target_file(
    original_path: &Path,
    target_path: &Path,
) -> Result<bool>
Expand description

Seeds a sibling temporary file first, then atomically creates a hard link at target_path. Other writers only see a complete copy, and linking does not overwrite a target another writer created. The temporary file is removed after the link is created (or after any error). Both paths are in the same directory, so they are on the same volume. A filesystem that cannot create a hard link fails the seed rather than exposing a partial target or modifying the original.

Returns Ok(true) if this call performed the seed, Ok(false) if another call already had (or was concurrently doing so), or Err for any other I/O failure.

ยงErrors

Returns an error if original_path cannot be read or the copy fails for a reason other than target_path already existing.