Browse Source

chatgui: db_path is now a directory (chat_data/) with chats.db and sync/ inside

- Default db_path changed from 'chats.db' to 'chat_data' directory
- chat_core_init receives <db_path>/chats.db
- db_sync receives <db_path> (creates <db_path>/sync internally)
- Directory auto-created on startup via QDir::mkpath
topo_upd
Evgeny 3 months ago
parent
commit
5b749d6cc8
  1. 3
      tools/chatgui/src/main.cpp
  2. 4
      tools/chatgui/transport/node_config.cpp
  3. 4
      tools/chatgui/transport/utun_node.cpp

3
tools/chatgui/src/main.cpp

@ -66,9 +66,10 @@ int main(int argc, char *argv[]) {
}
QString dbPath = cfg.dbPath();
if (dbPath.isEmpty()) dbPath = "chats.db";
if (dbPath.isEmpty()) dbPath = "chat_data";
if (!QDir::isAbsolutePath(dbPath))
dbPath = QCoreApplication::applicationDirPath() + "/" + dbPath;
QDir(dbPath).mkpath(".");
DbManager db;
MainWindow w(nullptr, &db, cfgPath, dbPath, cfg.debugFile(),

4
tools/chatgui/transport/node_config.cpp

@ -175,7 +175,7 @@ bool NodeConfig::create(const QString& nodeName, quint16 listenPort) {
if (listenPort > 0)
m_servers.append({"lan", QString("0.0.0.0:%1").arg(listenPort)});
if (m_dbPath.isEmpty())
m_dbPath = "chats.db";
m_dbPath = "chat_data";
return save();
}
@ -340,7 +340,7 @@ bool NodeConfig::save() {
}
out << "[gui]\n";
out << "db_path=" << (m_dbPath.isEmpty() ? "chats.db" : m_dbPath) << "\n";
out << "db_path=" << (m_dbPath.isEmpty() ? "chat_data" : m_dbPath) << "\n";
out << "debug_file=" << m_debugFile << "\n";
out << "debug_level=" << (m_debugLevel.isEmpty() ? "info" : m_debugLevel) << "\n";
out << "debug_categories=" << m_debugCategories << "\n\n";

4
tools/chatgui/transport/utun_node.cpp

@ -1,6 +1,7 @@
// utun_node.cpp — embedded uTun node running in a dedicated thread
#include "utun_node.h"
#include <cinttypes>
#include <QDir>
#include "../../lib/socket_compat.h"
#include "../db/db_manager.h"
@ -62,6 +63,7 @@ void UtunNode::setDebugFile(const QString& path) {
void UtunNode::setDbPath(const QString& path) {
m_dbPath = path;
QDir(path).mkpath(".");
}
void UtunNode::setDebugLevel(const QString& level) {
@ -245,7 +247,7 @@ void UtunNode::runLoop() {
etcp_router_bind(m_instance, ETCP_RT_ID_CHAT, recvCallback);
/* Initialize chat_core (DB) and chat_sync (channel/message P2P sync) */
chat_core_init(m_instance, m_dbPath.toUtf8().constData());
chat_core_init(m_instance, QString(m_dbPath + "/chats.db").toUtf8().constData());
chat_sync_init(m_instance, nullptr);
chat_sync_auto_connect_start(m_instance);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "chat_core + chat_sync + auto_connect initialized");

Loading…
Cancel
Save