mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-20 11:26:53 +00:00
Merge pull request #6524 from APriestman/fixHealthMontiorUpgrade2
Fix health monitor upgrade code 2
This commit is contained in:
commit
291a476be8
@ -183,6 +183,7 @@ public final class HealthMonitor implements PropertyChangeListener {
|
|||||||
if (conn == null) {
|
if (conn == null) {
|
||||||
throw new HealthMonitorException("Error getting database connection");
|
throw new HealthMonitorException("Error getting database connection");
|
||||||
}
|
}
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
|
||||||
try (Statement statement = conn.createStatement()) {
|
try (Statement statement = conn.createStatement()) {
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
@ -210,8 +211,13 @@ public final class HealthMonitor implements PropertyChangeListener {
|
|||||||
// Changes: username added to user_data table
|
// Changes: username added to user_data table
|
||||||
if (currentSchema.compareTo(new CaseDbSchemaVersionNumber(1, 2)) < 0) {
|
if (currentSchema.compareTo(new CaseDbSchemaVersionNumber(1, 2)) < 0) {
|
||||||
|
|
||||||
|
resultSet = statement.executeQuery("SELECT column_name " +
|
||||||
|
"FROM information_schema.columns " +
|
||||||
|
"WHERE table_name='user_data' and column_name='username'");
|
||||||
|
if (! resultSet.next()) {
|
||||||
// Add the user_data table
|
// Add the user_data table
|
||||||
statement.execute("ALTER TABLE user_data ADD COLUMN IF NOT EXISTS username text");
|
statement.execute("ALTER TABLE user_data ADD COLUMN username text");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the schema version
|
// Update the schema version
|
||||||
@ -228,6 +234,13 @@ public final class HealthMonitor implements PropertyChangeListener {
|
|||||||
}
|
}
|
||||||
throw new HealthMonitorException("Error upgrading database", ex);
|
throw new HealthMonitorException("Error upgrading database", ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
if (resultSet != null) {
|
||||||
|
try {
|
||||||
|
resultSet.close();
|
||||||
|
} catch (SQLException ex2) {
|
||||||
|
logger.log(Level.SEVERE, "Error closing result set");
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -971,7 +984,7 @@ public final class HealthMonitor implements PropertyChangeListener {
|
|||||||
getInstance().writeCurrentStateToDatabase();
|
getInstance().writeCurrentStateToDatabase();
|
||||||
}
|
}
|
||||||
} catch (HealthMonitorException ex) {
|
} catch (HealthMonitorException ex) {
|
||||||
logger.log(Level.SEVERE, "Error performing periodic task", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error recording health monitor metrics", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user