ksud: remove original file after copy

This commit is contained in:
tiann
2023-02-22 00:08:18 +08:00
parent bd3773f32a
commit 349fd09440

View File

@@ -224,13 +224,10 @@ pub fn on_boot_completed() -> Result<()> {
if module_update_img.exists() { if module_update_img.exists() {
// this is a update and we successfully booted // this is a update and we successfully booted
if std::fs::rename(module_update_img, module_img).is_err() { if std::fs::rename(module_update_img, module_img).is_err() {
warn!( warn!("Failed to rename images, copy it now.",);
"Failed to rename {} to {}, copy it now.",
module_update_img.display(),
module_img.display()
);
std::fs::copy(module_update_img, module_img) 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(()) Ok(())