From 349fd09440efa6ee4a2b9327a90e52bb50b5dc59 Mon Sep 17 00:00:00 2001 From: tiann Date: Wed, 22 Feb 2023 00:08:18 +0800 Subject: [PATCH] ksud: remove original file after copy --- userspace/ksud/src/event.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/userspace/ksud/src/event.rs b/userspace/ksud/src/event.rs index e62da740..a9129854 100644 --- a/userspace/ksud/src/event.rs +++ b/userspace/ksud/src/event.rs @@ -224,13 +224,10 @@ pub fn on_boot_completed() -> Result<()> { if module_update_img.exists() { // this is a update and we successfully booted if std::fs::rename(module_update_img, module_img).is_err() { - warn!( - "Failed to rename {} to {}, copy it now.", - module_update_img.display(), - module_img.display() - ); + warn!("Failed to rename images, copy it now.",); std::fs::copy(module_update_img, module_img) - .with_context(|| "Failed to copy modules_update.img to modules.img")?; + .with_context(|| "Failed to copy images")?; + std::fs::remove_file(module_update_img).with_context(|| "Failed to remove image!")?; } } Ok(())