uonedb-qt team mailing list archive
-
uonedb-qt team
-
Mailing list archive
-
Message #00322
[Merge] lp:~gcollura/u1db-qt/fix-1387294 into lp:u1db-qt
Giulio Collura has proposed merging lp:~gcollura/u1db-qt/fix-1387294 into lp:u1db-qt.
Commit message:
Make u1db-qt play nice with ~ as absolute directory.
Requested reviews:
U1DB Qt developers (uonedb-qt)
Related bugs:
Bug #1387294 in U1DB Qt/ QML: "u1db should accept ~ in database path"
https://bugs.launchpad.net/u1db-qt/+bug/1387294
For more details, see:
https://code.launchpad.net/~gcollura/u1db-qt/fix-1387294/+merge/240035
Fix for bug #1387294. Make u1db-qt play nice with ~ as absolute directory.
--
https://code.launchpad.net/~gcollura/u1db-qt/fix-1387294/+merge/240035
Your team U1DB Qt developers is requested to review the proposed merge of lp:~gcollura/u1db-qt/fix-1387294 into lp:u1db-qt.
=== modified file 'src/database.cpp'
--- src/database.cpp 2014-07-09 22:39:59 +0000
+++ src/database.cpp 2014-10-29 18:37:25 +0000
@@ -140,16 +140,21 @@
if (!m_db.isValid())
return setError("QSqlDatabase error");
- if (path != ":memory:" && QDir::isRelativePath(path)) {
+ if (path != ":memory:" && QDir::isRelativePath(path) && !path.contains("~")) {
QString dataPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
QString absolutePath(QDir(dataPath).absoluteFilePath(path));
QString parent(QFileInfo(absolutePath).dir().path());
if (!QDir().mkpath(parent))
qWarning() << "Failed to make data folder" << parent;
m_db.setDatabaseName(absolutePath);
+ } else {
+ QString absolutePath(path);
+ absolutePath.replace("~", QDir::homePath());
+ QString parent(QFileInfo(absolutePath).dir().path());
+ if (!QDir().mkpath(parent))
+ qWarning() << "Failed to make destination folder" << parent;
+ m_db.setDatabaseName(absolutePath);
}
- else
- m_db.setDatabaseName(path);
if (!m_db.open())
return setError(QString("Failed to open %1: %2").arg(path).arg(m_db.lastError().text()));
Follow ups