mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-09 19:43:31 +02:00
downloader: use native separators when building target file path
Also reverts waiting on the msiexec process + error checking. Change-Id: Icfd8c349087d1b9f84c95d855b68b7ef2e45b3ab
This commit is contained in:
parent
6a0963d37b
commit
f1ccd5d05d
8 changed files with 14 additions and 46 deletions
|
@ -335,10 +335,6 @@ ApplicationWindow {
|
|||
var errorStr = translateErrorToString(error);
|
||||
presentUpdateInfoDialog(errorStr);
|
||||
}
|
||||
|
||||
function onInstallErrorOccurred(errorMsg) {
|
||||
presentUpdateInfoDialog(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
onClosing: root.close()
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include <random>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -81,6 +81,5 @@ private:
|
|||
LRCInstance* lrcInstance_;
|
||||
AppSettingsManager* settingsManager_;
|
||||
std::mutex mtx_;
|
||||
QString tempPath_;
|
||||
QString baseUrl_;
|
||||
};
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue