Cleanup UX: slim logging, DBI keep config, no manifest overwrite
- Slim cleanup: one progress line per section (Bereinige: X [p%] (n/n)) via delete_path_lists_grouped() in clean and update mode - DBI: remove folder entries from deletion lists; only .nro deleted, folder and config preserved - Remove redundant manifest.ini creation; use manifest from pack config/ Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -138,11 +138,6 @@ static const char* clean_switch_dirs_to_delete[] = {
|
|||||||
"sd:/switch/ChoiDujourNX",
|
"sd:/switch/ChoiDujourNX",
|
||||||
"sd:/switch/crash_ams",
|
"sd:/switch/crash_ams",
|
||||||
"sd:/switch/Daybreak",
|
"sd:/switch/Daybreak",
|
||||||
"sd:/switch/DBI_658_EN",
|
|
||||||
"sd:/switch/DBI_810",
|
|
||||||
"sd:/switch/DBI_810_DE",
|
|
||||||
"sd:/switch/DBI_810_EN",
|
|
||||||
"sd:/switch/DBI_RU",
|
|
||||||
"sd:/switch/DNS_mitm Tester",
|
"sd:/switch/DNS_mitm Tester",
|
||||||
"sd:/switch/EdiZon",
|
"sd:/switch/EdiZon",
|
||||||
"sd:/switch/Fizeau",
|
"sd:/switch/Fizeau",
|
||||||
@@ -208,6 +203,8 @@ static const char* clean_switch_files_to_delete[] = {
|
|||||||
"sd:/switch/DBI_810_DE/DBI_810_DE.nro",
|
"sd:/switch/DBI_810_DE/DBI_810_DE.nro",
|
||||||
"sd:/switch/DBI_810_EN/DBI_810_EN.nro",
|
"sd:/switch/DBI_810_EN/DBI_810_EN.nro",
|
||||||
"sd:/switch/DBI_RU/DBI_RU.nro",
|
"sd:/switch/DBI_RU/DBI_RU.nro",
|
||||||
|
"sd:/switch/DBI/DBI_EN.nro",
|
||||||
|
"sd:/switch/DBI_DE/DBI_DE.nro",
|
||||||
"sd:/switch/DNS_mitm Tester.nro",
|
"sd:/switch/DNS_mitm Tester.nro",
|
||||||
"sd:/switch/EdiZon.nro",
|
"sd:/switch/EdiZon.nro",
|
||||||
"sd:/switch/Fizeau.nro",
|
"sd:/switch/Fizeau.nro",
|
||||||
|
|||||||
@@ -137,11 +137,6 @@ static const char* switch_dirs_to_delete[] = {
|
|||||||
"sd:/switch/ChoiDujourNX",
|
"sd:/switch/ChoiDujourNX",
|
||||||
"sd:/switch/crash_ams",
|
"sd:/switch/crash_ams",
|
||||||
"sd:/switch/Daybreak",
|
"sd:/switch/Daybreak",
|
||||||
"sd:/switch/DBI_658_EN",
|
|
||||||
"sd:/switch/DBI_810",
|
|
||||||
"sd:/switch/DBI_810_DE",
|
|
||||||
"sd:/switch/DBI_810_EN",
|
|
||||||
"sd:/switch/DBI_RU",
|
|
||||||
"sd:/switch/DNS_mitm Tester",
|
"sd:/switch/DNS_mitm Tester",
|
||||||
"sd:/switch/EdiZon",
|
"sd:/switch/EdiZon",
|
||||||
"sd:/switch/Fizeau",
|
"sd:/switch/Fizeau",
|
||||||
@@ -207,6 +202,8 @@ static const char* switch_files_to_delete[] = {
|
|||||||
"sd:/switch/DBI_810_DE/DBI_810_DE.nro",
|
"sd:/switch/DBI_810_DE/DBI_810_DE.nro",
|
||||||
"sd:/switch/DBI_810_EN/DBI_810_EN.nro",
|
"sd:/switch/DBI_810_EN/DBI_810_EN.nro",
|
||||||
"sd:/switch/DBI_RU/DBI_RU.nro",
|
"sd:/switch/DBI_RU/DBI_RU.nro",
|
||||||
|
"sd:/switch/DBI/DBI_EN.nro",
|
||||||
|
"sd:/switch/DBI_DE/DBI_DE.nro",
|
||||||
"sd:/switch/DNS_mitm Tester.nro",
|
"sd:/switch/DNS_mitm Tester.nro",
|
||||||
"sd:/switch/EdiZon.nro",
|
"sd:/switch/EdiZon.nro",
|
||||||
"sd:/switch/Fizeau.nro",
|
"sd:/switch/Fizeau.nro",
|
||||||
|
|||||||
@@ -7,9 +7,12 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
#include <libs/fatfs/ff.h>
|
#include <libs/fatfs/ff.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utils/sprintf.h>
|
#include <utils/sprintf.h>
|
||||||
|
|
||||||
|
#define GROUPED_DELETE_MAX_ENTRIES 512
|
||||||
|
|
||||||
#ifndef VERSION
|
#ifndef VERSION
|
||||||
#define VERSION "1.0.0"
|
#define VERSION "1.0.0"
|
||||||
#endif
|
#endif
|
||||||
@@ -395,6 +398,89 @@ int folder_delete_single_with_progress(const char *path, const char *display_nam
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete a list of paths with progress tracking
|
// Delete a list of paths with progress tracking
|
||||||
|
// Delete multiple path lists under one label; one progress line "Bereinige: folder/ [p%] (d/t)".
|
||||||
|
// Varargs: path lists (const char**), terminated by NULL.
|
||||||
|
int delete_path_lists_grouped(const char *folder_display_name, ...) {
|
||||||
|
va_list ap;
|
||||||
|
const char *entries[GROUPED_DELETE_MAX_ENTRIES];
|
||||||
|
int n_entries = 0;
|
||||||
|
int deleted = 0;
|
||||||
|
int failed = 0;
|
||||||
|
u32 start_x, start_y;
|
||||||
|
int last_percent = -1;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
va_start(ap, folder_display_name);
|
||||||
|
const char **list;
|
||||||
|
while (n_entries < GROUPED_DELETE_MAX_ENTRIES && (list = va_arg(ap, const char **)) != NULL) {
|
||||||
|
for (int i = 0; list[i] != NULL && n_entries < GROUPED_DELETE_MAX_ENTRIES; i++) {
|
||||||
|
if (install_path_exists(list[i]))
|
||||||
|
entries[n_entries++] = list[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (n_entries == 0)
|
||||||
|
return FR_OK;
|
||||||
|
|
||||||
|
int total_paths = n_entries;
|
||||||
|
gfx_con_getpos(&start_x, &start_y);
|
||||||
|
install_set_color(COLOR_CYAN);
|
||||||
|
gfx_printf(" Bereinige: %s [ 0%%] (0/%d)", folder_display_name, total_paths);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
|
||||||
|
for (int i = 0; i < n_entries; i++) {
|
||||||
|
const char *path = entries[i];
|
||||||
|
FILINFO fno;
|
||||||
|
if (f_stat(path, &fno) != FR_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const char *item_name = strrchr(path, '/');
|
||||||
|
if (item_name) item_name++;
|
||||||
|
else item_name = path;
|
||||||
|
|
||||||
|
if (fno.fattrib & AM_DIR) {
|
||||||
|
int item_count = install_count_directory_items(path);
|
||||||
|
if (item_count > 50) {
|
||||||
|
gfx_printf("\n");
|
||||||
|
res = folder_delete_single_with_progress(path, item_name);
|
||||||
|
} else {
|
||||||
|
res = folder_delete(path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (fno.fattrib & AM_RDO)
|
||||||
|
f_chmod(path, fno.fattrib & ~AM_RDO, AM_RDO);
|
||||||
|
res = f_unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == FR_OK || res == FR_NO_FILE)
|
||||||
|
deleted++;
|
||||||
|
else
|
||||||
|
failed++;
|
||||||
|
|
||||||
|
int percent = (deleted * 100) / total_paths;
|
||||||
|
if (percent != last_percent || deleted % 5 == 0) {
|
||||||
|
gfx_con_setpos(start_x, start_y);
|
||||||
|
install_set_color(COLOR_CYAN);
|
||||||
|
gfx_printf(" Bereinige: %s [%3d%%] (%d/%d)", folder_display_name, percent, deleted, total_paths);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
last_percent = percent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx_con_setpos(start_x, start_y);
|
||||||
|
if (failed == 0) {
|
||||||
|
install_set_color(COLOR_GREEN);
|
||||||
|
gfx_printf(" Bereinige: %s [100%%] (%d/%d) - Fertig!\n", folder_display_name, deleted, total_paths);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
} else {
|
||||||
|
install_set_color(COLOR_ORANGE);
|
||||||
|
gfx_printf(" Bereinige: %s [%3d%%] (%d/%d) - %d Fehler\n", folder_display_name, last_percent, deleted, total_paths, failed);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
}
|
||||||
|
return (failed == 0) ? FR_OK : FR_DISK_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
int delete_path_list(const char* paths[], const char* description) {
|
int delete_path_list(const char* paths[], const char* description) {
|
||||||
int res;
|
int res;
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ bool install_path_exists(const char *path);
|
|||||||
int install_count_directory_items(const char *path);
|
int install_count_directory_items(const char *path);
|
||||||
void install_combine_path(char *result, size_t size, const char *base, const char *add);
|
void install_combine_path(char *result, size_t size, const char *base, const char *add);
|
||||||
int delete_path_list(const char* paths[], const char* description);
|
int delete_path_list(const char* paths[], const char* description);
|
||||||
|
int delete_path_lists_grouped(const char *folder_display_name, ...);
|
||||||
int folder_delete_single_with_progress(const char *path, const char *display_name);
|
int folder_delete_single_with_progress(const char *path, const char *display_name);
|
||||||
int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent);
|
int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent);
|
||||||
int folder_copy_with_progress_v2(const char *src, const char *dst, const char *display_name);
|
int folder_copy_with_progress_v2(const char *src, const char *dst, const char *display_name);
|
||||||
|
|||||||
@@ -49,41 +49,36 @@ int clean_mode_backup(void) {
|
|||||||
int clean_mode_wipe(void) {
|
int clean_mode_wipe(void) {
|
||||||
check_and_clear_screen_if_needed();
|
check_and_clear_screen_if_needed();
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
|
||||||
gfx_printf(" Bereinige: atmosphere/\n");
|
|
||||||
set_color(COLOR_WHITE);
|
set_color(COLOR_WHITE);
|
||||||
delete_path_list(clean_atmosphere_dirs_to_delete, "atmosphere subdirs");
|
delete_path_lists_grouped("atmosphere/",
|
||||||
delete_path_list(clean_atmosphere_contents_dirs_to_delete, "atmosphere contents dirs");
|
clean_atmosphere_dirs_to_delete,
|
||||||
delete_path_list(clean_atmosphere_files_to_delete, "atmosphere files");
|
clean_atmosphere_contents_dirs_to_delete,
|
||||||
|
clean_atmosphere_files_to_delete,
|
||||||
|
NULL);
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("bootloader/",
|
||||||
gfx_printf(" Bereinige: bootloader/\n");
|
clean_bootloader_dirs_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
clean_bootloader_files_to_delete,
|
||||||
delete_path_list(clean_bootloader_dirs_to_delete, "bootloader dirs");
|
NULL);
|
||||||
delete_path_list(clean_bootloader_files_to_delete, "bootloader files");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("config/",
|
||||||
gfx_printf(" Bereinige: config/\n");
|
clean_config_dirs_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
NULL);
|
||||||
delete_path_list(clean_config_dirs_to_delete, "config dirs");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("switch/",
|
||||||
gfx_printf(" Bereinige: switch/\n");
|
clean_switch_dirs_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
clean_switch_files_to_delete,
|
||||||
delete_path_list(clean_switch_dirs_to_delete, "switch dirs");
|
NULL);
|
||||||
delete_path_list(clean_switch_files_to_delete, "switch files");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("Root-Dateien",
|
||||||
gfx_printf(" Bereinige: Root-Dateien\n");
|
clean_root_files_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
clean_misc_dirs_to_delete,
|
||||||
delete_path_list(clean_root_files_to_delete, "root files");
|
clean_misc_files_to_delete,
|
||||||
delete_path_list(clean_misc_dirs_to_delete, "misc dirs");
|
NULL);
|
||||||
delete_path_list(clean_misc_files_to_delete, "misc files");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("Alte Versionsmarker",
|
||||||
gfx_printf(" Bereinige: Alte Versionsmarker\n");
|
old_version_files_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
NULL);
|
||||||
delete_path_list(old_version_files_to_delete, "old version markers");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
set_color(COLOR_CYAN);
|
||||||
gfx_printf(" Erstelle: switch/\n");
|
gfx_printf(" Erstelle: switch/\n");
|
||||||
|
|||||||
@@ -39,36 +39,32 @@ int update_mode_cleanup(omninx_variant_t variant) {
|
|||||||
(void)variant;
|
(void)variant;
|
||||||
check_and_clear_screen_if_needed();
|
check_and_clear_screen_if_needed();
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
|
||||||
gfx_printf(" Bereinige: atmosphere/\n");
|
|
||||||
set_color(COLOR_WHITE);
|
set_color(COLOR_WHITE);
|
||||||
delete_path_list(atmosphere_dirs_to_delete, "atmosphere subdirs");
|
delete_path_lists_grouped("atmosphere/",
|
||||||
delete_path_list(atmosphere_contents_dirs_to_delete, "atmosphere contents dirs");
|
atmosphere_dirs_to_delete,
|
||||||
delete_path_list(atmosphere_files_to_delete, "atmosphere files");
|
atmosphere_contents_dirs_to_delete,
|
||||||
|
atmosphere_files_to_delete,
|
||||||
|
NULL);
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("bootloader/",
|
||||||
gfx_printf(" Bereinige: bootloader/\n");
|
bootloader_dirs_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
bootloader_files_to_delete,
|
||||||
delete_path_list(bootloader_dirs_to_delete, "bootloader dirs");
|
NULL);
|
||||||
delete_path_list(bootloader_files_to_delete, "bootloader files");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("config/",
|
||||||
gfx_printf(" Bereinige: config/\n");
|
config_dirs_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
NULL);
|
||||||
delete_path_list(config_dirs_to_delete, "config dirs");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("switch/",
|
||||||
gfx_printf(" Bereinige: switch/\n");
|
switch_dirs_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
switch_files_to_delete,
|
||||||
delete_path_list(switch_dirs_to_delete, "switch dirs");
|
NULL);
|
||||||
delete_path_list(switch_files_to_delete, "switch files");
|
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
delete_path_lists_grouped("Root-Dateien",
|
||||||
gfx_printf(" Bereinige: Root-Dateien\n");
|
root_files_to_delete,
|
||||||
set_color(COLOR_WHITE);
|
misc_dirs_to_delete,
|
||||||
delete_path_list(root_files_to_delete, "root files");
|
misc_files_to_delete,
|
||||||
delete_path_list(misc_dirs_to_delete, "misc dirs");
|
NULL);
|
||||||
delete_path_list(misc_files_to_delete, "misc files");
|
|
||||||
|
|
||||||
set_color(COLOR_GREEN);
|
set_color(COLOR_GREEN);
|
||||||
gfx_printf(" Bereinigung abgeschlossen!\n");
|
gfx_printf(" Bereinigung abgeschlossen!\n");
|
||||||
@@ -148,40 +144,6 @@ int update_mode_install(omninx_variant_t variant) {
|
|||||||
s_printf(dst_path, "sd:/payload.bin");
|
s_printf(dst_path, "sd:/payload.bin");
|
||||||
if (path_exists(src_path)) file_copy(src_path, dst_path);
|
if (path_exists(src_path)) file_copy(src_path, dst_path);
|
||||||
|
|
||||||
set_color(COLOR_CYAN);
|
|
||||||
gfx_printf(" Erstelle manifest.ini...\n");
|
|
||||||
set_color(COLOR_WHITE);
|
|
||||||
|
|
||||||
s_printf(dst_path, "sd:/config/omninx");
|
|
||||||
f_mkdir(dst_path);
|
|
||||||
|
|
||||||
const char* pack_name;
|
|
||||||
int update_channel;
|
|
||||||
switch (variant) {
|
|
||||||
case VARIANT_STANDARD: pack_name = "Standard"; update_channel = 2; break;
|
|
||||||
case VARIANT_LIGHT: pack_name = "Light"; update_channel = 0; break;
|
|
||||||
case VARIANT_OC: pack_name = "OC"; update_channel = 1; break;
|
|
||||||
default: pack_name = "unknown"; update_channel = 0; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_printf(dst_path, "sd:/config/omninx/manifest.ini");
|
|
||||||
FIL fp;
|
|
||||||
if (f_open(&fp, dst_path, FA_WRITE | FA_CREATE_ALWAYS) == FR_OK) {
|
|
||||||
f_printf(&fp, "[OmniNX]\n");
|
|
||||||
f_printf(&fp, "current_pack=%s\n", pack_name);
|
|
||||||
f_printf(&fp, "version=%s\n", VERSION);
|
|
||||||
f_printf(&fp, "update_channel=%d\n", update_channel);
|
|
||||||
f_printf(&fp, "channel_pack=%s\n", pack_name);
|
|
||||||
f_close(&fp);
|
|
||||||
set_color(COLOR_GREEN);
|
|
||||||
gfx_printf(" [OK] manifest.ini erstellt\n");
|
|
||||||
set_color(COLOR_WHITE);
|
|
||||||
} else {
|
|
||||||
set_color(COLOR_ORANGE);
|
|
||||||
gfx_printf(" [WARN] manifest.ini konnte nicht erstellt werden\n");
|
|
||||||
set_color(COLOR_WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_color(COLOR_GREEN);
|
set_color(COLOR_GREEN);
|
||||||
gfx_printf(" Kopie abgeschlossen!\n");
|
gfx_printf(" Kopie abgeschlossen!\n");
|
||||||
set_color(COLOR_WHITE);
|
set_color(COLOR_WHITE);
|
||||||
|
|||||||
Reference in New Issue
Block a user