dbhub: Make sure the directories for the remote code exist

When the directories for the cloned remote databases or for our meta
database do not yet exist create them.

See issue #2327.
This commit is contained in:
Martin Kleusberg
2020-07-13 22:54:20 +02:00
parent 5d89bb8991
commit 4d62e4b82a
2 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -644,7 +644,7 @@ void PreferencesDialog::chooseRemoteCloneDirectory()
tr("Choose a directory"),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(!s.isEmpty())
if(!s.isEmpty() && QDir().mkpath(s))
ui->editRemoteCloneDirectory->setText(s);
}
+7 -3
View File
@@ -646,14 +646,18 @@ void RemoteDatabase::localAssureOpened()
if(m_dbLocal)
return;
// Open file
QString database_file = QStandardPaths::writableLocation(
// Make sure the directory exists
QString database_directory = QStandardPaths::writableLocation(
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QStandardPaths::AppDataLocation
#else
QStandardPaths::GenericDataLocation
#endif
) + "/remotedbs.db";
);
QDir().mkpath(database_directory);
// Open file
QString database_file = database_directory + "/remotedbs.db";
if(sqlite3_open_v2(database_file.toUtf8(), &m_dbLocal, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr) != SQLITE_OK)
{
QMessageBox::warning(nullptr, qApp->applicationName(), tr("Error opening local databases list.\n%1").arg(QString::fromUtf8(sqlite3_errmsg(m_dbLocal))));