Skip to content

Commit

Permalink
Simple bug fix
Browse files Browse the repository at this point in the history
Fixed a bug where clicking "Restart" when previous data was found in SQLite would just lead to an endless loop as SQLite data was not purged upon restart.
  • Loading branch information
Skullians committed Mar 24, 2024
1 parent cbbdcb5 commit dcf1ab1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ void confirmContinuation(MouseEvent event) {
}

@FXML
void restartSelection(MouseEvent event) { switchPage("main"); }
void restartSelection(MouseEvent event) {
try {
LOGGER.warning("User chose to restart the searching! Purging SQLite Data...");
MainApp.database.purgeData();
LOGGER.warning("Successfully purged data.");
switchPage("main");
} catch (SQLException error) {
ErrorHandler.error = "An error occurred when trying to reset SQLite Data: \n" + error.getMessage();
ErrorHandler.setErrorMessage(borderPane);
LOGGER.severe("An error occurred when trying to reset SQLite Data: \n" + error.getMessage());
error.printStackTrace();
}
}

private void switchPage(String pageName) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,21 @@ public ConfigModel getConfigsIfExists(String folderPath) throws SQLException {
}


// ------------------------ 'RESET' ------------------------ //


public void purgeData() throws SQLException {
try (Connection connection = dataSource.getConnection();
PreparedStatement configDataPurge = connection.prepareStatement("DELETE FROM configData");
PreparedStatement dependenciesDataPurge = connection.prepareStatement("DELETE FROM dependenciesData")) {

configDataPurge.executeUpdate();
dependenciesDataPurge.executeUpdate();

configDataPurge.close();
dependenciesDataPurge.close();

connection.close();
}
}
}

0 comments on commit dcf1ab1

Please sign in to comment.