From f1ccd5d05dc6f9f7da95afd97256085e610650e6 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Thu, 5 Oct 2023 19:01:25 -0400 Subject: [PATCH] downloader: use native separators when building target file path Also reverts waiting on the msiexec process + error checking. Change-Id: Icfd8c349087d1b9f84c95d855b68b7ef2e45b3ab --- src/app/MainApplicationWindow.qml | 4 ---- src/app/appversionmanager.cpp | 39 +++++++------------------------ src/app/appversionmanager.h | 1 - src/app/networkmanager.cpp | 2 +- src/app/networkmanager.h | 1 + src/app/pluginadapter.cpp | 2 -- src/app/pluginadapter.h | 1 - src/app/pluginversionmanager.cpp | 10 ++++---- 8 files changed, 14 insertions(+), 46 deletions(-) diff --git a/src/app/MainApplicationWindow.qml b/src/app/MainApplicationWindow.qml index 31fe17bd8..55776ccac 100644 --- a/src/app/MainApplicationWindow.qml +++ b/src/app/MainApplicationWindow.qml @@ -335,10 +335,6 @@ ApplicationWindow { var errorStr = translateErrorToString(error); presentUpdateInfoDialog(errorStr); } - - function onInstallErrorOccurred(errorMsg) { - presentUpdateInfoDialog(errorMsg); - } } onClosing: root.close() diff --git a/src/app/appversionmanager.cpp b/src/app/appversionmanager.cpp index ba6cd6730..8284765ec 100644 --- a/src/app/appversionmanager.cpp +++ b/src/app/appversionmanager.cpp @@ -44,7 +44,6 @@ struct AppVersionManager::Impl : public QObject , parent_(parent) , lrcInstance_(instance) , baseUrlString_(url.isEmpty() ? downloadUrl : url) - , tempPath_(QDir::tempPath()) , updateTimer_(new QTimer(this)) { connect(updateTimer_, &QTimer::timeout, this, [this] { @@ -105,41 +104,20 @@ struct AppVersionManager::Impl : public QObject parent_.replyId_ = parent_.downloadFile( downloadUrl, lastDownloadReplyId, - [this, downloadUrl](bool success, const QString& errorMessage) { + [downloadUrl](bool success, const QString& errorMessage) { Q_UNUSED(success) Q_UNUSED(errorMessage) QProcess process; - auto basePath = tempPath_ + QDir::separator(); + auto basePath = QDir::tempPath() + QDir::separator(); auto msiPath = QDir::toNativeSeparators(basePath + downloadUrl.fileName()); auto logPath = QDir::toNativeSeparators(basePath + "jami_x64_install.log"); - connect(&process, &QProcess::errorOccurred, this, [&](QProcess::ProcessError error) { - QString errorMsg; - if (error == QProcess::ProcessError::Timedout) { - errorMsg = tr("The installer process has timed out."); - } else { - errorMsg = process.readAllStandardError(); - if (errorMsg.isEmpty()) - errorMsg = tr("The installer process has failed."); - } - Q_EMIT parent_.installErrorOccurred(errorMsg); - }); - connect(&process, - &QProcess::finished, - this, - [&](int exitCode, QProcess::ExitStatus exitStatus) { - if (exitStatus != QProcess::ExitStatus::NormalExit || exitCode != 0) { - auto errorMsg = process.readAllStandardOutput(); - Q_EMIT parent_.installErrorOccurred(errorMsg); - } - }); - process.start("msiexec", - QStringList() << "/i" << msiPath << "/passive" - << "/norestart" - << "WIXNONUILAUNCH=1" - << "/L*V" << logPath); - process.waitForFinished(); + process.startDetached("msiexec", + QStringList() << "/i" << msiPath << "/passive" + << "/norestart" + << "WIXNONUILAUNCH=1" + << "/L*V" << logPath); }, - tempPath_); + QDir::tempPath()); }; void cancelUpdate() @@ -179,7 +157,6 @@ struct AppVersionManager::Impl : public QObject LRCInstance* lrcInstance_ {nullptr}; QString baseUrlString_; - QString tempPath_; QTimer* updateTimer_; }; diff --git a/src/app/appversionmanager.h b/src/app/appversionmanager.h index e2a2539ed..84e0095c5 100644 --- a/src/app/appversionmanager.h +++ b/src/app/appversionmanager.h @@ -48,7 +48,6 @@ Q_SIGNALS: void updateCheckReplyReceived(bool ok, bool found = false); void updateDownloadProgressChanged(qint64 bytesRead, qint64 totalBytes); void networkErrorOccurred(const NetworkManager::GetError& error); - void installErrorOccurred(const QString& errorMsg); private: int replyId_; diff --git a/src/app/networkmanager.cpp b/src/app/networkmanager.cpp index dc31bd21b..c66284b5f 100644 --- a/src/app/networkmanager.cpp +++ b/src/app/networkmanager.cpp @@ -155,7 +155,7 @@ NetworkManager::downloadFile(const QUrl& url, const QFileInfo fileInfo(url.path()); const QString fileName = fileInfo.fileName(); auto& file = files_[uuid]; - file = new QFile(filePath + fileName + extension); + file = new QFile(filePath + QDir::separator() + fileName + extension); if (!file->open(QIODevice::WriteOnly)) { Q_EMIT errorOccurred(GetError::ACCESS_DENIED); files_.remove(uuid); diff --git a/src/app/networkmanager.h b/src/app/networkmanager.h index dc8b27333..3433546fd 100644 --- a/src/app/networkmanager.h +++ b/src/app/networkmanager.h @@ -23,6 +23,7 @@ #include <QMap> #include <QString> #include <QNetworkReply> + #include <random> class QNetworkAccessManager; diff --git a/src/app/pluginadapter.cpp b/src/app/pluginadapter.cpp index ccc23df89..f5bd1ab37 100644 --- a/src/app/pluginadapter.cpp +++ b/src/app/pluginadapter.cpp @@ -44,8 +44,6 @@ PluginAdapter::PluginAdapter(LRCInstance* instance, , pluginListModel_(new PluginListModel(instance, this)) , lrcInstance_(instance) , settingsManager_(settingsManager) - , tempPath_(QDir::tempPath()) - { QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, pluginStoreListModel_, "PluginStoreListModel"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, pluginListModel_, "PluginListModel") diff --git a/src/app/pluginadapter.h b/src/app/pluginadapter.h index f79d35384..afd02c263 100644 --- a/src/app/pluginadapter.h +++ b/src/app/pluginadapter.h @@ -81,6 +81,5 @@ private: LRCInstance* lrcInstance_; AppSettingsManager* settingsManager_; std::mutex mtx_; - QString tempPath_; QString baseUrl_; }; diff --git a/src/app/pluginversionmanager.cpp b/src/app/pluginversionmanager.cpp index e6a177e7f..a08518fc3 100644 --- a/src/app/pluginversionmanager.cpp +++ b/src/app/pluginversionmanager.cpp @@ -35,7 +35,6 @@ public: , parent_(parent) , settingsManager_(new AppSettingsManager(this)) , lrcInstance_(instance) - , tempPath_(QDir::tempPath()) , updateTimer_(new QTimer(this)) { connect(updateTimer_, &QTimer::timeout, this, [this] { checkForUpdates(); }); @@ -133,9 +132,9 @@ public: return; } QThreadPool::globalInstance()->start([this, pluginId] { - auto res = lrcInstance_->pluginModel().installPlugin(QDir(tempPath_).filePath( - pluginId + ".jpl"), - true); + auto res = lrcInstance_->pluginModel() + .installPlugin(QDir(QDir::tempPath()).filePath(pluginId + ".jpl"), + true); if (res) { parent_.versionStatusChanged(pluginId, PluginStatus::Role::INSTALLED); } else { @@ -144,7 +143,7 @@ public: }); parent_.versionStatusChanged(pluginId, PluginStatus::Role::INSTALLING); }, - tempPath_ + '/'); + QDir::tempPath()); Q_EMIT parent_.versionStatusChanged(pluginId, PluginStatus::Role::DOWNLOADING); } @@ -161,7 +160,6 @@ public: PluginVersionManager& parent_; AppSettingsManager* settingsManager_ {nullptr}; LRCInstance* lrcInstance_ {nullptr}; - QString tempPath_; QTimer* updateTimer_; }; -- GitLab