Merge lp:~gcollura/u1db-qt/fix-1387294 into lp:u1db-qt

Proposed by Giulio Collura
Status: Needs review
Proposed branch: lp:~gcollura/u1db-qt/fix-1387294
Merge into: lp:u1db-qt
Diff against target: 32 lines (+12/-9)
1 file modified
src/database.cpp (+12/-9)
To merge this branch: bzr merge lp:~gcollura/u1db-qt/fix-1387294
Reviewer Review Type Date Requested Status
Michał Karnicki Needs Information
Cris Dywan Needs Information
Review via email: mp+240035@code.launchpad.net

Commit message

Make u1db-qt play nice with ~ as absolute directory.

Description of the change

Fix for bug #1387294. Make u1db-qt play nice with ~ as absolute directory.

To post a comment you must log in.
lp:~gcollura/u1db-qt/fix-1387294 updated
121. By Giulio Collura

improve codestyle

Revision history for this message
Michał Karnicki (karni) wrote :

Looks good to me. Can we please have someone from U1DB Qt devs review and advise on how we get this landed? Thanks.

Revision history for this message
Cris Dywan (kalikiana) wrote :

My immediate concern is that this isn't addressing the use case it was motivated by - if settings stored in U1Db should go to the config folder, ~ is the wrong approach.

review: Needs Information
Revision history for this message
Giulio Collura (gcollura) wrote :

What would you suggest instead? We would like to have the chance to use .config for all data app. We can add another property to Database that stores the destination folder, for example:
Database {
  path: 'hello.db'
  location: Database.ConfigLocation
}
I'm not sure about the naming convention, the default option would be Database.DataLocation.
These would be values of an enum exported to qml.
Let me know what you think about this solution.

Giulio

Revision history for this message
Michał Karnicki (karni) wrote :

I have mixed feelings. Let's not forget U1DB can also be used by desktop apps, which currently are not confined and apparmor restrictions do not apply.

Revision history for this message
Michał Karnicki (karni) wrote :

Hi Christian,

Have you made decision how you want to proceed with this bug? Soon this will affect Telegram, where (IIUC) there no longer is 'phablet' user in the new image.

review: Needs Information

Unmerged revisions

121. By Giulio Collura

improve codestyle

120. By Giulio Collura

Fix bug #1387294. Improve database path creation.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/database.cpp'
--- src/database.cpp 2014-07-09 22:39:59 +0000
+++ src/database.cpp 2014-10-29 19:48:43 +0000
@@ -140,16 +140,19 @@
140 if (!m_db.isValid())140 if (!m_db.isValid())
141 return setError("QSqlDatabase error");141 return setError("QSqlDatabase error");
142142
143 if (path != ":memory:" && QDir::isRelativePath(path)) {143 QString absolutePath;
144 if (path != ":memory:" && QDir::isRelativePath(path) && !path.contains("~")) {
144 QString dataPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));145 QString dataPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
145 QString absolutePath(QDir(dataPath).absoluteFilePath(path));146 absolutePath = QDir(dataPath).absoluteFilePath(path);
146 QString parent(QFileInfo(absolutePath).dir().path());147 }
147 if (!QDir().mkpath(parent))148 else {
148 qWarning() << "Failed to make data folder" << parent;149 absolutePath = path;
149 m_db.setDatabaseName(absolutePath);150 absolutePath.replace("~", QDir::homePath());
150 }151 }
151 else152 QString parent(QFileInfo(absolutePath).dir().path());
152 m_db.setDatabaseName(path);153 if (!QDir().mkpath(parent))
154 qWarning() << "Failed to make destination folder" << parent;
155 m_db.setDatabaseName(absolutePath);
153156
154 if (!m_db.open())157 if (!m_db.open())
155 return setError(QString("Failed to open %1: %2").arg(path).arg(m_db.lastError().text()));158 return setError(QString("Failed to open %1: %2").arg(path).arg(m_db.lastError().text()));

Subscribers

People subscribed via source and target branches

to all changes: