Files
OmniNX-Installer-Payload/source/install_update.c
T
niklascfw 664216fa11 Move pack files instead of copying; one file-op core for all modes
Install: staging and sd:/ are on the same card, so pack folders are now
moved with f_rename (a missing target folder moves in one step, existing
ones are merged file by file). Copying is only a per-entry fallback.
The staging cleanup afterwards only removes empty folders.

Deletion: one f_stat per list entry, no full recursive count before
deleting; large folders are detected with a probe that stops after 51
entries. Progress lines count processed entries instead of needing an
extra pass for a total.

Six copy/delete walkers (fs.c + install.c) are replaced by fs_delete_tree,
fs_move_tree and fs_move_file sharing one path buffer and one copy buffer
per run; the 'alternative copy method' retry is gone. extras/hekate-ams-pro
is moved too. Backups keep copy semantics.
2026-11-12 22:57:26 +01:00

147 lines
3.9 KiB
C

/*
* OmniNX Installer - Update Mode
* Selective cleanup and install when OmniNX is already installed.
*/
#include "install.h"
#include "deletion_lists_update.h"
#include "fs.h"
#include "version.h"
#include "gfx.h"
#include <libs/fatfs/ff.h>
#include <string.h>
#include <utils/sprintf.h>
#undef COLOR_CYAN
#undef COLOR_WHITE
#undef COLOR_GREEN
#undef COLOR_YELLOW
#undef COLOR_ORANGE
#undef COLOR_RED
#define COLOR_CYAN 0xFF00FFFF
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_GREEN 0xFF00FF00
#define COLOR_YELLOW 0xFFFFDD00
#define COLOR_ORANGE 0xFF00A5FF
#define COLOR_RED 0xFFFF0000
#define set_color install_set_color
#define check_and_clear_screen_if_needed install_check_and_clear_screen_if_needed
#define path_exists install_path_exists
// Update mode: Cleanup specific directories/files
int update_mode_cleanup(omninx_variant_t variant) {
(void)variant;
install_preserve_update_cleanup_begin();
check_and_clear_screen_if_needed();
set_color(COLOR_WHITE);
delete_path_lists_grouped("atmosphere/",
atmosphere_dirs_to_delete,
atmosphere_contents_dirs_to_delete,
atmosphere_files_to_delete,
NULL);
delete_path_lists_grouped("bootloader/",
bootloader_dirs_to_delete,
bootloader_files_to_delete,
NULL);
delete_path_lists_grouped("config/",
config_dirs_to_delete,
NULL);
delete_path_lists_grouped("switch/",
switch_dirs_to_delete,
switch_files_to_delete,
NULL);
delete_path_lists_grouped("Root-Dateien",
root_files_to_delete,
misc_dirs_to_delete,
misc_files_to_delete,
NULL);
install_preserve_update_cleanup_end();
set_color(COLOR_GREEN);
gfx_printf(" Bereinigung abgeschlossen!\n");
set_color(COLOR_WHITE);
return FR_OK;
}
// Pack folders installed from staging (SaltySD only ships with OC).
static const char *const pack_folders[] = {
"atmosphere", "bootloader", "config", "switch", "themes",
"warmboot_mariko", "hwtest", "SaltySD", "extras",
};
// Update mode: Move files from staging (rename on the same SD card, copy only as fallback)
int update_mode_install(omninx_variant_t variant) {
int res;
const char* staging = get_staging_path(variant);
char src_path[FS_PATH_MAX];
char label[32];
if (!staging) {
return FR_INVALID_PARAMETER;
}
check_and_clear_screen_if_needed();
set_color(COLOR_YELLOW);
gfx_printf("Dateien werden installiert...\n");
set_color(COLOR_WHITE);
for (u32 i = 0; i < sizeof(pack_folders) / sizeof(pack_folders[0]); i++) {
if (!strcmp(pack_folders[i], "SaltySD") && variant != VARIANT_OC)
continue;
s_printf(src_path, "%s/%s", staging, pack_folders[i]);
s_printf(label, "%s/", pack_folders[i]);
res = install_move_tree(src_path, "sd:/", label);
if (res != FR_OK && res != FR_NO_FILE)
return res;
}
set_color(COLOR_CYAN);
gfx_printf(" Installiere Root-Dateien...\n");
set_color(COLOR_WHITE);
res = install_move_staging_root_files(staging, "sd:/");
if (res != FR_OK)
return res;
set_color(COLOR_GREEN);
gfx_printf(" Installation der Dateien abgeschlossen!\n");
set_color(COLOR_WHITE);
return FR_OK;
}
// Remove staging directory after installation (mostly empty folders after the move)
int cleanup_staging_directory(omninx_variant_t pack_variant) {
const char* staging = get_staging_path(pack_variant);
if (!staging) {
return FR_INVALID_PARAMETER;
}
check_and_clear_screen_if_needed();
if (!path_exists(staging))
return FR_OK;
set_color(COLOR_YELLOW);
gfx_printf("\nEntferne Installationsordner...\n");
set_color(COLOR_WHITE);
int res = install_delete_tree(staging);
if (res != FR_OK) {
set_color(COLOR_ORANGE);
gfx_printf(" [WARN] Ordner konnte nicht entfernt werden (err=%d)\n", res);
set_color(COLOR_WHITE);
}
return res;
}