Add env-var XDG_RUNTIME_DIR

This commit is contained in:
Gerhard Hoffmann 2023-05-26 13:02:45 +02:00
parent de75ef32d9
commit 71a6b82d58

View File

@ -5,7 +5,6 @@
#include <QFileInfo>
#include "message_handler.h"
#include "interfaces.h"
#include "DCPlugin/include/hwapi.h"
@ -15,6 +14,7 @@
#include <QSharedMemory>
#include <QRunnable>
#include <QThreadPool>
#include <QDir>
#include "update.h"
@ -26,12 +26,16 @@
class Work : public QRunnable {
QString m_update_ctrl_file;
QString m_workingDir;
public:
explicit Work(QString update_ctrl_file)
: m_update_ctrl_file(update_ctrl_file) {}
explicit Work(QString update_ctrl_file, QString workingDir)
: m_update_ctrl_file(update_ctrl_file)
, m_workingDir(workingDir) {
}
void run() {
Update m_update(m_update_ctrl_file);
m_update.doUpdate();
Update m_update(m_update_ctrl_file, m_workingDir);
// if (m_update.doUpdate()) {
// }
}
};
@ -45,13 +49,15 @@ int main(int argc, char *argv[]) {
//setDebugLevel(QtMsgType::QtDebugMsg);
}
QString update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv";
if (argc == 2) {
update_ctrl_file = argv[1];
QByteArray const value = qgetenv("XDG_RUNTIME_DIR");
if (value.size() == 0) {
qputenv("XDG_RUNTIME_DIR", "/run/user/0");
}
qInfo() << "Using" << update_ctrl_file << "as update logfile";
Work work(update_ctrl_file);
QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv";
QString const workingDir = (argc == 2) ? argv[1] : ".";
Work work(update_ctrl_file, workingDir);
work.setAutoDelete(false);
QThreadPool *threadPool = QThreadPool::globalInstance();
threadPool->start(&work);