Browse Source

chatgui: пути db и лога относительные в конфиге, резолв к бинарнику в рантайме

v2
evgeny 4 weeks ago
parent
commit
d092f649ac
  1. 10
      tools/chatgui/src/main.cpp
  2. 2
      tools/chatgui/transport/node_config.cpp

10
tools/chatgui/src/main.cpp

@ -130,22 +130,14 @@ int main(int argc, char *argv[]) {
if (!QDir::isAbsolutePath(dbPath)) if (!QDir::isAbsolutePath(dbPath))
dbPath = QCoreApplication::applicationDirPath() + "/" + dbPath; dbPath = QCoreApplication::applicationDirPath() + "/" + dbPath;
QDir(dbPath).mkpath("."); QDir(dbPath).mkpath(".");
if (cfg.dbPath() != dbPath) {
cfg.setDbPath(dbPath);
cfg.save();
}
QString debugFile = cfg.debugFile(); QString debugFile = cfg.debugFile();
if (debugFile.isEmpty()) debugFile = "chatgui.log"; if (debugFile.isEmpty()) debugFile = "chatgui.log";
if (!QDir::isAbsolutePath(debugFile)) if (!QDir::isAbsolutePath(debugFile))
debugFile = QCoreApplication::applicationDirPath() + "/" + debugFile; debugFile = QCoreApplication::applicationDirPath() + "/" + debugFile;
if (cfg.debugFile() != debugFile) {
cfg.setDebugFile(debugFile);
cfg.save();
}
DbManager db; DbManager db;
MainWindow w(nullptr, &db, cfgPath, dbPath, cfg.debugFile(), MainWindow w(nullptr, &db, cfgPath, dbPath, debugFile,
cfg.debugLevel(), cfg.debugCategories()); cfg.debugLevel(), cfg.debugCategories());
w.show(); w.show();

2
tools/chatgui/transport/node_config.cpp

@ -358,7 +358,6 @@ bool NodeConfig::saveFull() {
if (!m_privKey.isEmpty()) out << "my_private_key=" << m_privKey << "\n"; if (!m_privKey.isEmpty()) out << "my_private_key=" << m_privKey << "\n";
if (!m_pubKey.isEmpty()) out << "my_public_key=" << m_pubKey << "\n"; if (!m_pubKey.isEmpty()) out << "my_public_key=" << m_pubKey << "\n";
out << "auto_sockets=" << (m_autoSockets ? "yes" : "no") << "\n"; out << "auto_sockets=" << (m_autoSockets ? "yes" : "no") << "\n";
out << "db_path=" << (m_dbPath.isEmpty() ? "chat_data" : m_dbPath) << "\n";
out << "\n"; out << "\n";
for (auto& srv : m_servers) { for (auto& srv : m_servers) {
@ -433,7 +432,6 @@ bool NodeConfig::save() {
config_update_in_lines(lines, "global", "my_private_key", m_privKey, true); config_update_in_lines(lines, "global", "my_private_key", m_privKey, true);
config_update_in_lines(lines, "global", "my_public_key", m_pubKey, true); config_update_in_lines(lines, "global", "my_public_key", m_pubKey, true);
config_update_in_lines(lines, "global", "auto_sockets", m_autoSockets ? "yes" : "no", true); config_update_in_lines(lines, "global", "auto_sockets", m_autoSockets ? "yes" : "no", true);
config_update_in_lines(lines, "global", "db_path", m_dbPath.isEmpty() ? "chat_data" : m_dbPath, true);
if (!m_controlAddr.isEmpty()) { if (!m_controlAddr.isEmpty()) {
int sep = m_controlAddr.lastIndexOf(':'); int sep = m_controlAddr.lastIndexOf(':');

Loading…
Cancel
Save