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.
This commit is contained in:
niklascfw committed 2026-11-12 22:57:26 +01:00
1 parent c033b988ca
commit 664216fa11
6 files changed
+453 -784

No files matched your search

+34 -78
View File
@@ -28,7 +28,6 @@
#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
#define count_directory_items install_count_directory_items
// Update mode: Cleanup specific directories/files
int update_mode_cleanup(omninx_variant_t variant) {
@@ -73,11 +72,18 @@ int update_mode_cleanup(omninx_variant_t variant) {
return FR_OK;
}
// Update mode: Copy files from staging
// 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[256];
char src_path[FS_PATH_MAX];
char label[32];
if (!staging) {
return FR_INVALID_PARAMETER;
@@ -86,63 +92,35 @@ int update_mode_install(omninx_variant_t variant) {
check_and_clear_screen_if_needed();
set_color(COLOR_YELLOW);
gfx_printf("Dateien werden kopiert...\n");
gfx_printf("Dateien werden installiert...\n");
set_color(COLOR_WHITE);
s_printf(src_path, "%s/atmosphere", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "atmosphere/");
if (res != FR_OK && res != FR_NO_FILE) return res;
s_printf(src_path, "%s/bootloader", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "bootloader/");
if (res != FR_OK && res != FR_NO_FILE) return res;
s_printf(src_path, "%s/config", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "config/");
if (res != FR_OK && res != FR_NO_FILE) return res;
s_printf(src_path, "%s/switch", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "switch/");
if (res != FR_OK && res != FR_NO_FILE) return res;
s_printf(src_path, "%s/themes", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "themes/");
if (res != FR_OK && res != FR_NO_FILE) return res;
s_printf(src_path, "%s/warmboot_mariko", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "warmboot_mariko/");
if (res != FR_OK && res != FR_NO_FILE) return res;
s_printf(src_path, "%s/hwtest", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "hwtest/");
if (res != FR_OK && res != FR_NO_FILE) return res;
if (variant == VARIANT_OC) {
s_printf(src_path, "%s/SaltySD", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "SaltySD/");
if (res != FR_OK && res != FR_NO_FILE) return res;
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;
}
s_printf(src_path, "%s/extras", staging);
res = folder_copy_with_progress_v2(src_path, "sd:/", "extras/");
if (res != FR_OK && res != FR_NO_FILE) return res;
set_color(COLOR_CYAN);
gfx_printf(" Kopiere Root-Dateien...\n");
gfx_printf(" Installiere Root-Dateien...\n");
set_color(COLOR_WHITE);
res = install_copy_staging_root_files(staging, "sd:/");
res = install_move_staging_root_files(staging, "sd:/");
if (res != FR_OK)
return res;
set_color(COLOR_GREEN);
gfx_printf(" Kopie abgeschlossen!\n");
gfx_printf(" Installation der Dateien abgeschlossen!\n");
set_color(COLOR_WHITE);
return FR_OK;
}
// Remove staging directory after installation
// 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) {
@@ -151,40 +129,18 @@ int cleanup_staging_directory(omninx_variant_t pack_variant) {
check_and_clear_screen_if_needed();
if (path_exists(staging)) {
set_color(COLOR_YELLOW);
gfx_printf("\nEntferne Installationsordner...\n");
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);
int total = count_directory_items(staging);
u32 start_x, start_y;
gfx_con_getpos(&start_x, &start_y);
const char *folder_name = strrchr(staging, '/');
if (folder_name) folder_name++;
else folder_name = staging;
set_color(COLOR_CYAN);
gfx_printf(" Loesche: %s [ 0%%] (0/%d)", folder_name, total);
set_color(COLOR_WHITE);
int deleted = 0;
int last_percent = -1;
int res = folder_delete_progress_recursive(staging, &deleted, total, start_x, start_y, folder_name, &last_percent);
gfx_con_setpos(start_x, start_y);
if (res == FR_OK) {
set_color(COLOR_GREEN);
gfx_printf(" Loesche: %s [100%%] (%d/%d) - Fertig!\n", folder_name, deleted, total);
set_color(COLOR_WHITE);
} else {
set_color(COLOR_ORANGE);
gfx_printf(" Loesche: %s - Fehlgeschlagen!\n", folder_name);
gfx_printf(" [WARN] Ordner konnte nicht entfernt werden (err=%d)\n", res);
set_color(COLOR_WHITE);
}
return res;
}
return FR_OK;
return res;
}