mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-24 22:48:23 -05:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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))));
|
||||
|
||||
Reference in New Issue
Block a user