aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 20b4a113..cd4c9838 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -1949,7 +1949,7 @@ void Connection::Private::saveDevicesList()
QElapsedTimer et;
et.start();
- QFile outFile { q->stateCacheDir().filePath("deviceslist.json") };
+ QFile outFile { q->e2eeDataDir() + QStringLiteral("/deviceslist.json") };
if (!outFile.open(QFile::WriteOnly)) {
qCWarning(E2EE) << "Error opening" << outFile.fileName() << ":"
<< outFile.errorString();
@@ -1997,7 +1997,7 @@ void Connection::Private::saveDevicesList()
void Connection::Private::loadDevicesList()
{
- QFile file { q->stateCacheDir().filePath("deviceslist.json") };
+ QFile file { q->e2eeDataDir() + QStringLiteral("/deviceslist.json") };
if(!file.exists() || !file.open(QIODevice::ReadOnly)) {
qCDebug(E2EE) << "No devicesList cache exists. Creating new";
return;
@@ -2050,3 +2050,15 @@ void Connection::saveOlmAccount()
AccountSettings(d->data->userId()).setEncryptionAccountPickle(std::get<QByteArray>(pickle));
//TODO handle errors
}
+
+QString Connection::e2eeDataDir() const
+{
+ auto safeUserId = userId();
+ safeUserId.replace(':', '_');
+ const QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) % '/'
+ % safeUserId % '/';
+ QDir dir;
+ if (!dir.exists(path))
+ dir.mkpath(path);
+ return path;
+}