Merge pull request #180 from t-h-i-s-u-s-e-r-n-a-m-e-i-s-c-a-n-c-e-r/patch-1

Add a check for file writability to the DB to confuse users slightly less.
This commit is contained in:
Rose Witchaven 2021-08-10 16:59:08 -05:00 committed by GitHub
commit ec45370a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include <QSqlDriver>
#include <QSqlError>
#include <QSqlQuery>
#include <QFileInfo>
/**
* @brief A class used to handle database interaction.

View File

@ -20,6 +20,11 @@
DBManager::DBManager() :
DRIVER("QSQLITE")
{
const QString db_filename = "config/akashi.db";
QFileInfo db_info(db_filename);
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");
if (!db.open())