Fix application crash when exiting due to failure state (#2244)

* Fix a potential crash when an unclean exit is performed and any database access cannot be cleanly shutdown
This commit is contained in:
abraunegg 2022-12-04 20:20:55 +11:00 committed by GitHub
parent 0b89a1fea0
commit 19727d9c57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -503,8 +503,14 @@ final class ItemDatabase
// Perform a vacuum on the database, commit WAL / SHM to file
void performVacuum()
{
auto stmt = db.prepare("VACUUM;");
stmt.exec();
try {
auto stmt = db.prepare("VACUUM;");
stmt.exec();
} catch (SqliteException e) {
writeln();
log.error("ERROR: Unable to perform a database vacuum: " ~ e.msg);
writeln();
}
}
// Select distinct driveId items from database