Skip to main content

atomic_replace

Function atomic_replace 

Source
pub async fn atomic_replace(
    source: &Path,
    target: &Path,
) -> Result<(), UpdateKitError>
Expand description

Atomically replace the file at target with the contents of source.

On Unix: copies source to a temp file next to target, sets executable permissions (0o755), then renames over the target (atomic on the same filesystem). Cleans up the temp file on failure.

On Windows: renames target to .old, copies source to target, then removes the .old file. Rolls back on copy failure.