From 4277605804f2eb358e6e8e62443b5b406811f362 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 4 Apr 2024 02:02:10 -0700 Subject: [PATCH] Fix some export bugs --- src/ui/exportscreen.c | 14 +++++++++----- src/util.c | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ui/exportscreen.c b/src/ui/exportscreen.c index 83d9ff1..c008a19 100644 --- a/src/ui/exportscreen.c +++ b/src/ui/exportscreen.c @@ -115,6 +115,7 @@ static void export_select_drive(ExportScreen *screen, ++screen->cur_drive; screen->need_redraw = true; } + Drive *drive = &screen->drives[screen->cur_drive]; if (screen->need_redraw) { screen->need_redraw = false; lcd_clear(state->lcd); @@ -122,14 +123,18 @@ static void export_select_drive(ExportScreen *screen, lcd_write_string(state->lcd, "Drive:"); lcd_move_to(state->lcd, 1, 0); lcd_write_char(state->lcd, '>'); - lcd_write_string(state->lcd, screen->drives[screen->cur_drive].name); + lcd_write_string(state->lcd, drive->name); lcd_write_char(state->lcd, ' '); - lcd_write_string(state->lcd, screen->drives[screen->cur_drive].fs); + if (drive->fs) { + lcd_write_string(state->lcd, drive->fs); + } else { + lcd_write_string(state->lcd, "no FS"); + } lcd_move_to(state->lcd, 1, 0); } if (state->sel_down) { screen->need_redraw = true; - if (!screen->drives[screen->cur_drive].fs) { + if (!drive->fs) { screen->stage = EXPORT_SCREEN_CONFIRM_NEWFS; } else { screen->stage = EXPORT_SCREEN_MOUNTING; @@ -317,12 +322,11 @@ static bool export_screen_dispatch(ExportScreen *screen, } if (screen->read_drives) { screen->drives = drive_list_usb_drives(&screen->ndrive); + screen->read_drives = false; if (screen->ndrive == 0) { screen->stage = EXPORT_SCREEN_NO_DRIVES; - screen->need_redraw =true; } else { screen->cur_drive = 0; - screen->read_drives = false; } } Drive *cur_drive = &screen->drives[screen->cur_drive]; diff --git a/src/util.c b/src/util.c index ef47e61..73e9276 100644 --- a/src/util.c +++ b/src/util.c @@ -522,6 +522,7 @@ bool export_database_as_csv(sqlite3 *db, const char *dest) { status = false; goto cleanup; // readability } + fflush(outfile); cleanup: pthread_cleanup_pop(true); // reset query pthread_cleanup_pop(true); // close file