install: backup and restore HorizonOC config.ini on OC pack update
- Copy sd:/config/horizon-oc/config.ini to sd:/.omninx_oc_update before update cleanup/copy; restore after Hekate step, then remove the scratch dir. - Only when INSTALL_MODE_UPDATE and VARIANT_OC. Made-with: Cursor
This commit is contained in:
@@ -101,3 +101,34 @@ int cleanup_backup(void) {
|
||||
}
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
int backup_horizon_oc_config_for_oc_update(void) {
|
||||
if (!path_exists(HORIZON_OC_CONFIG_PATH))
|
||||
return FR_OK;
|
||||
|
||||
int res = f_mkdir(HORIZON_OC_UPDATE_BACKUP_DIR);
|
||||
if (res != FR_OK && res != FR_EXIST)
|
||||
return res;
|
||||
|
||||
return file_copy(HORIZON_OC_CONFIG_PATH, HORIZON_OC_UPDATE_BACKUP_INI);
|
||||
}
|
||||
|
||||
int restore_horizon_oc_config_after_oc_update(void) {
|
||||
if (!path_exists(HORIZON_OC_UPDATE_BACKUP_INI))
|
||||
return FR_OK;
|
||||
|
||||
int res = f_mkdir("sd:/config");
|
||||
if (res != FR_OK && res != FR_EXIST)
|
||||
return res;
|
||||
res = f_mkdir("sd:/config/horizon-oc");
|
||||
if (res != FR_OK && res != FR_EXIST)
|
||||
return res;
|
||||
|
||||
return file_copy(HORIZON_OC_UPDATE_BACKUP_INI, HORIZON_OC_CONFIG_PATH);
|
||||
}
|
||||
|
||||
int cleanup_horizon_oc_update_backup(void) {
|
||||
if (!path_exists(HORIZON_OC_UPDATE_BACKUP_DIR))
|
||||
return FR_OK;
|
||||
return folder_delete(HORIZON_OC_UPDATE_BACKUP_DIR);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
#define TEMP_BACKUP_PATH "sd:/temp_backup"
|
||||
|
||||
/** Live HorizonOC settings (Overclock tool). */
|
||||
#define HORIZON_OC_CONFIG_PATH "sd:/config/horizon-oc/config.ini"
|
||||
/** Scratch dir during OC-variant update only; removed after successful restore. */
|
||||
#define HORIZON_OC_UPDATE_BACKUP_DIR "sd:/.omninx_oc_update"
|
||||
#define HORIZON_OC_UPDATE_BACKUP_INI HORIZON_OC_UPDATE_BACKUP_DIR "/config.ini"
|
||||
|
||||
// Backup user data (DBI, Tinfoil, prod.keys) before clean install
|
||||
int backup_user_data(void);
|
||||
|
||||
@@ -16,3 +22,10 @@ int restore_user_data(void);
|
||||
|
||||
// Clean up temporary backup directory
|
||||
int cleanup_backup(void);
|
||||
|
||||
// HorizonOC: backup config.ini before OC pack update (update mode only); no-op if missing
|
||||
int backup_horizon_oc_config_for_oc_update(void);
|
||||
// Restore after file copy; no-op if no backup from this run
|
||||
int restore_horizon_oc_config_after_oc_update(void);
|
||||
// Delete sd:/.omninx_oc_update after successful restore
|
||||
int cleanup_horizon_oc_update_backup(void);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
#include "backup.h"
|
||||
#include "fs.h"
|
||||
#include "screenshot.h"
|
||||
#include "version.h"
|
||||
@@ -872,6 +873,21 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
|
||||
int res;
|
||||
|
||||
if (mode == INSTALL_MODE_UPDATE) {
|
||||
if (pack_variant == VARIANT_OC) {
|
||||
bool had_horizon_cfg = install_path_exists(HORIZON_OC_CONFIG_PATH);
|
||||
install_set_color(COLOR_YELLOW);
|
||||
gfx_printf("HorizonOC: Sichere config.ini...\n");
|
||||
install_set_color(COLOR_WHITE);
|
||||
res = backup_horizon_oc_config_for_oc_update();
|
||||
if (res != FR_OK)
|
||||
return res;
|
||||
if (had_horizon_cfg) {
|
||||
install_set_color(COLOR_GREEN);
|
||||
gfx_printf(" [OK] Bestehende config.ini gesichert.\n");
|
||||
install_set_color(COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
// Update mode: selective cleanup then install
|
||||
install_set_color(COLOR_YELLOW);
|
||||
gfx_printf("Schritt 1: Bereinigung...\n");
|
||||
@@ -889,6 +905,26 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
|
||||
|
||||
install_hekate_8gb_post_copy();
|
||||
|
||||
if (pack_variant == VARIANT_OC) {
|
||||
bool had_horizon_bak = install_path_exists(HORIZON_OC_UPDATE_BACKUP_INI);
|
||||
install_check_and_clear_screen_if_needed();
|
||||
install_set_color(COLOR_YELLOW);
|
||||
gfx_printf("HorizonOC: Stelle config.ini wieder her...\n");
|
||||
install_set_color(COLOR_WHITE);
|
||||
res = restore_horizon_oc_config_after_oc_update();
|
||||
if (res != FR_OK)
|
||||
return res;
|
||||
install_set_color(COLOR_GREEN);
|
||||
if (had_horizon_bak)
|
||||
gfx_printf(" [OK] Deine HorizonOC-Einstellungen wurden wiederhergestellt.\n");
|
||||
else
|
||||
gfx_printf(" [OK] Keine fruehere config.ini — Standard aus dem Paket bleibt.\n");
|
||||
install_set_color(COLOR_WHITE);
|
||||
res = cleanup_horizon_oc_update_backup();
|
||||
if (res != FR_OK)
|
||||
return res;
|
||||
}
|
||||
|
||||
install_check_and_clear_screen_if_needed();
|
||||
// Remove staging directory (installed pack)
|
||||
res = cleanup_staging_directory(pack_variant);
|
||||
|
||||
Reference in New Issue
Block a user