From a7e3fb508eb15ac0dd53e53ebed75e86542c1fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20L=C3=A9onard?= <anthony.leonard@savoirfairelinux.com> Date: Mon, 16 Oct 2017 15:51:15 -0400 Subject: [PATCH] database: create directory path for ring.db MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Sébastien Blin <sebastien.blin@savoirfairelinux.com> --- src/database.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/database.cpp b/src/database.cpp index 6f7c7166..32654565 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -31,6 +31,7 @@ #include <QtSql/QSqlRecord> #include <QtCore/QStandardPaths> #include <QtCore/QVariant> +#include <QDir> // Std #include <sstream> @@ -59,6 +60,12 @@ Database::Database() 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. db_ = QSqlDatabase::addDatabase("QSQLITE"); #ifdef ENABLE_TEST -- GitLab