Merge pull request #212 from Salanto/db-shenanigans

Fix database permission error when database is first created
This commit is contained in:
Rosemary Witchaven 2021-10-04 15:22:58 -05:00 committed by GitHub
commit 535134db98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,8 +22,14 @@ DBManager::DBManager() :
{
const QString db_filename = "config/akashi.db";
QFileInfo db_info(db_filename);
if (!db_info.exists()) {
qWarning().noquote() << tr("Database Info: Database not found. Attempting to create new database.");
}
else {
//We should only check if a file is readable/writeable when it actually exists.
if(!db_info.isReadable() || !db_info.isWritable())
qCritical() << tr("Database Error: Missing permissions. Check if \"%1\" is writable.").arg(db_filename);
}
db = QSqlDatabase::addDatabase(DRIVER);
db.setDatabaseName("config/akashi.db");