diff --git a/main.cpp b/main.cpp index 8941d18..d2aeb84 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,6 @@ #include #include "message_handler.h" - #include "interfaces.h" #include "DCPlugin/include/hwapi.h" @@ -15,6 +14,7 @@ #include #include #include +#include #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);