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:
commit
ec45370a71
@ -29,6 +29,7 @@
|
|||||||
#include <QSqlDriver>
|
#include <QSqlDriver>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class used to handle database interaction.
|
* @brief A class used to handle database interaction.
|
||||||
|
@ -20,6 +20,11 @@
|
|||||||
DBManager::DBManager() :
|
DBManager::DBManager() :
|
||||||
DRIVER("QSQLITE")
|
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 = QSqlDatabase::addDatabase(DRIVER);
|
||||||
db.setDatabaseName("config/akashi.db");
|
db.setDatabaseName("config/akashi.db");
|
||||||
if (!db.open())
|
if (!db.open())
|
||||||
|
Loading…
Reference in New Issue
Block a user