From 97bfeb7bd8093b42d4cd745f9f45af0c48a70098 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 23 Jun 2022 21:27:30 +1000 Subject: [PATCH] Use `atomic_install` in `install_bin` Signed-off-by: Jiahao XU --- src/bins.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bins.rs b/src/bins.rs index 76dfc9fc..18134f70 100644 --- a/src/bins.rs +++ b/src/bins.rs @@ -4,7 +4,7 @@ use cargo_toml::Product; use log::debug; use serde::Serialize; -use crate::{BinstallError, PkgFmt, PkgMeta, Template}; +use crate::{atomic_install, BinstallError, PkgFmt, PkgMeta, Template}; pub struct BinFile { pub base_name: String, @@ -80,11 +80,11 @@ impl BinFile { pub fn install_bin(&self) -> Result<(), BinstallError> { // TODO: check if file already exists debug!( - "Copy file from '{}' to '{}'", + "Atomically install file from '{}' to '{}'", self.source.display(), self.dest.display() ); - std::fs::copy(&self.source, &self.dest)?; + atomic_install(&self.source, &self.dest)?; #[cfg(target_family = "unix")] {