Skip to content
Snippets Groups Projects
Commit a7e3fb50 authored by Anthony Léonard's avatar Anthony Léonard
Browse files

database: create directory path for ring.db


On Windows, database file creation fails if any folders of its path
isn't already existing. This small patch ensures this is done before
attempting to open ring.db

Change-Id: I545a7b4ac0015a62a4e36553df997e7d229243a5
Reviewed-by: default avatarSébastien Blin <sebastien.blin@savoirfairelinux.com>
parent d888ea6b
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <QtSql/QSqlRecord> #include <QtSql/QSqlRecord>
#include <QtCore/QStandardPaths> #include <QtCore/QStandardPaths>
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include <QDir>
// Std // Std
#include <sstream> #include <sstream>
...@@ -59,6 +60,12 @@ Database::Database() ...@@ -59,6 +60,12 @@ Database::Database()
throw std::runtime_error("QSQLITE not supported"); throw std::runtime_error("QSQLITE not supported");
} }
{
// create data directory if not created yet
QDir dataDir;
dataDir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
}
// initalize the database. // initalize the database.
db_ = QSqlDatabase::addDatabase("QSQLITE"); db_ = QSqlDatabase::addDatabase("QSQLITE");
#ifdef ENABLE_TEST #ifdef ENABLE_TEST
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment