Use atomic_install in install_bin

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-23 21:27:30 +10:00
parent 7616546a61
commit 97bfeb7bd8
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -4,7 +4,7 @@ use cargo_toml::Product;
use log::debug; use log::debug;
use serde::Serialize; use serde::Serialize;
use crate::{BinstallError, PkgFmt, PkgMeta, Template}; use crate::{atomic_install, BinstallError, PkgFmt, PkgMeta, Template};
pub struct BinFile { pub struct BinFile {
pub base_name: String, pub base_name: String,
@ -80,11 +80,11 @@ impl BinFile {
pub fn install_bin(&self) -> Result<(), BinstallError> { pub fn install_bin(&self) -> Result<(), BinstallError> {
// TODO: check if file already exists // TODO: check if file already exists
debug!( debug!(
"Copy file from '{}' to '{}'", "Atomically install file from '{}' to '{}'",
self.source.display(), self.source.display(),
self.dest.display() self.dest.display()
); );
std::fs::copy(&self.source, &self.dest)?; atomic_install(&self.source, &self.dest)?;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
{ {