ksud: delete modules_update when flag not exist

This commit is contained in:
tiann
2023-01-04 17:06:21 +08:00
parent bd93095abb
commit d8f5d74ec3

View File

@@ -13,13 +13,18 @@ pub fn on_post_data_fs() -> Result<()> {
// modules.img is the default image // modules.img is the default image
let mut target_update_img = &module_img; let mut target_update_img = &module_img;
if Path::new(module_update_img).exists() && module_update_flag.exists() { if Path::new(module_update_img).exists() {
// if modules_update.img exists, and the the flag indicate this is an update if module_update_flag.exists() {
// this make sure that if the update failed, we will fallback to the old image // if modules_update.img exists, and the the flag indicate this is an update
// if we boot succeed, we will rename the modules_update.img to modules.img #on_boot_complete // this make sure that if the update failed, we will fallback to the old image
target_update_img = &module_update_img; // if we boot succeed, we will rename the modules_update.img to modules.img #on_boot_complete
// And we should delete the flag immediately target_update_img = &module_update_img;
std::fs::remove_file(module_update_flag)?; // And we should delete the flag immediately
std::fs::remove_file(module_update_flag)?;
} else {
// if modules_update.img exists, but the flag not exist, we should delete it
std::fs::remove_file(module_update_img)?;
}
} }
if !Path::new(target_update_img).exists() { if !Path::new(target_update_img).exists() {