Fix some export bugs

This commit is contained in:
Alexander Rosenberg 2024-04-04 02:02:10 -07:00
parent 6ae67c4732
commit 4277605804
Signed by: school-rpi4
GPG Key ID: 5CCFC80B0B47B04B
2 changed files with 10 additions and 5 deletions

View File

@ -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];

View File

@ -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