1
0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-05 20:26:52 +00:00

nyx: fix restore logic when backup does not match emmc

- If sd backup size exceeds eMMC size, bail out.
- If partial files backup is smaller allow restoring in case user has an eMMC upgrade.
 Following the same behavior that single file backup has when it's smaller.
This commit is contained in:
CTCaer 2021-05-12 11:47:25 +03:00
parent 7181683d8e
commit 6316d3076d

View File

@ -987,14 +987,23 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
if (f_stat(outFilename, &fno) && !gui->raw_emummc)
if ((u32)((u64)totalCheckFileSize >> (u64)9) > totalSectors)
{
s_printf(gui->txt_buf, "#FFDD00 Error (%d) file not found#\n#FFDD00 %s.#\n#FFDD00 Aborting...#", res, outFilename);
s_printf(gui->txt_buf, "#FF8000 Size of SD Card split backup exceeds#\n#FF8000 eMMC's selected part size!#\n#FFDD00 Aborting...#");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
}
else if (f_stat(outFilename, &fno) && !gui->raw_emummc)
{
s_printf(gui->txt_buf, "#FFDD00 Error (%d) file not found#\n#FFDD00 %s.#\n\n", res, outFilename);
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
// Attempt a smaller restore.
break;
}
else if (f_stat(outFilename, &fno) && gui->raw_emummc)
{
totalSectors = (u32)((u64)totalCheckFileSize >> (u64)9);
@ -1026,7 +1035,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
{
lv_obj_t *warn_mbox_bg = create_mbox_text(
"#FF8000 Size of SD Card split backup does not match,#\n#FF8000 eMMC's selected part size!#\n\n"
"#FFDD00 The backup might be corrupted!#\n#FFDD00 Aborting is suggested!#\n\n"
"#FFDD00 The backup might be corrupted,#\n#FFDD00 or missing files!#\n#FFDD00 Aborting is suggested!#\n\n"
"Press #FF8000 POWER# to Continue.\nPress #FF8000 VOL# to abort.", false);
manual_system_maintenance(true);
@ -1084,7 +1093,17 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
}
else if (!use_multipart && (((u32)((u64)f_size(&fp) >> (u64)9)) != totalSectors)) // Check total restore size vs emmc size.
{
if (!gui->raw_emummc)
if (((u32)((u64)f_size(&fp) >> (u64)9)) > totalSectors)
{
s_printf(gui->txt_buf, "#FF8000 Size of SD Card backup exceeds#\n#FF8000 eMMC's selected part size!#\n#FFDD00 Aborting...#");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
f_close(&fp);
return 0;
}
else if (!gui->raw_emummc)
{
lv_obj_t *warn_mbox_bg = create_mbox_text(
"#FF8000 Size of the SD Card backup does not match,#\n#FF8000 eMMC's selected part size!#\n\n"