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);
|
var errorStr = translateErrorToString(error);
|
||||||
presentUpdateInfoDialog(errorStr);
|
presentUpdateInfoDialog(errorStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInstallErrorOccurred(errorMsg) {
|
|
||||||
presentUpdateInfoDialog(errorMsg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosing: root.close()
|
onClosing: root.close()
|
||||||
|
|
|
@ -44,7 +44,6 @@ struct AppVersionManager::Impl : public QObject
|
||||||
, parent_(parent)
|
, parent_(parent)
|
||||||
, lrcInstance_(instance)
|
, lrcInstance_(instance)
|
||||||
, baseUrlString_(url.isEmpty() ? downloadUrl : url)
|
, baseUrlString_(url.isEmpty() ? downloadUrl : url)
|
||||||
, tempPath_(QDir::tempPath())
|
|
||||||
, updateTimer_(new QTimer(this))
|
, updateTimer_(new QTimer(this))
|
||||||
{
|
{
|
||||||
connect(updateTimer_, &QTimer::timeout, this, [this] {
|
connect(updateTimer_, &QTimer::timeout, this, [this] {
|
||||||
|
@ -105,41 +104,20 @@ struct AppVersionManager::Impl : public QObject
|
||||||
parent_.replyId_ = parent_.downloadFile(
|
parent_.replyId_ = parent_.downloadFile(
|
||||||
downloadUrl,
|
downloadUrl,
|
||||||
lastDownloadReplyId,
|
lastDownloadReplyId,
|
||||||
[this, downloadUrl](bool success, const QString& errorMessage) {
|
[downloadUrl](bool success, const QString& errorMessage) {
|
||||||
Q_UNUSED(success)
|
Q_UNUSED(success)
|
||||||
Q_UNUSED(errorMessage)
|
Q_UNUSED(errorMessage)
|
||||||
QProcess process;
|
QProcess process;
|
||||||
auto basePath = tempPath_ + QDir::separator();
|
auto basePath = QDir::tempPath() + QDir::separator();
|
||||||
auto msiPath = QDir::toNativeSeparators(basePath + downloadUrl.fileName());
|
auto msiPath = QDir::toNativeSeparators(basePath + downloadUrl.fileName());
|
||||||
auto logPath = QDir::toNativeSeparators(basePath + "jami_x64_install.log");
|
auto logPath = QDir::toNativeSeparators(basePath + "jami_x64_install.log");
|
||||||
connect(&process, &QProcess::errorOccurred, this, [&](QProcess::ProcessError error) {
|
process.startDetached("msiexec",
|
||||||
QString errorMsg;
|
QStringList() << "/i" << msiPath << "/passive"
|
||||||
if (error == QProcess::ProcessError::Timedout) {
|
<< "/norestart"
|
||||||
errorMsg = tr("The installer process has timed out.");
|
<< "WIXNONUILAUNCH=1"
|
||||||
} else {
|
<< "/L*V" << logPath);
|
||||||
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();
|
|
||||||
},
|
},
|
||||||
tempPath_);
|
QDir::tempPath());
|
||||||
};
|
};
|
||||||
|
|
||||||
void cancelUpdate()
|
void cancelUpdate()
|
||||||
|
@ -179,7 +157,6 @@ struct AppVersionManager::Impl : public QObject
|
||||||
|
|
||||||
LRCInstance* lrcInstance_ {nullptr};
|
LRCInstance* lrcInstance_ {nullptr};
|
||||||
QString baseUrlString_;
|
QString baseUrlString_;
|
||||||
QString tempPath_;
|
|
||||||
QTimer* updateTimer_;
|
QTimer* updateTimer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ Q_SIGNALS:
|
||||||
void updateCheckReplyReceived(bool ok, bool found = false);
|
void updateCheckReplyReceived(bool ok, bool found = false);
|
||||||
void updateDownloadProgressChanged(qint64 bytesRead, qint64 totalBytes);
|
void updateDownloadProgressChanged(qint64 bytesRead, qint64 totalBytes);
|
||||||
void networkErrorOccurred(const NetworkManager::GetError& error);
|
void networkErrorOccurred(const NetworkManager::GetError& error);
|
||||||
void installErrorOccurred(const QString& errorMsg);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int replyId_;
|
int replyId_;
|
||||||
|
|
|
@ -155,7 +155,7 @@ NetworkManager::downloadFile(const QUrl& url,
|
||||||
const QFileInfo fileInfo(url.path());
|
const QFileInfo fileInfo(url.path());
|
||||||
const QString fileName = fileInfo.fileName();
|
const QString fileName = fileInfo.fileName();
|
||||||
auto& file = files_[uuid];
|
auto& file = files_[uuid];
|
||||||
file = new QFile(filePath + fileName + extension);
|
file = new QFile(filePath + QDir::separator() + fileName + extension);
|
||||||
if (!file->open(QIODevice::WriteOnly)) {
|
if (!file->open(QIODevice::WriteOnly)) {
|
||||||
Q_EMIT errorOccurred(GetError::ACCESS_DENIED);
|
Q_EMIT errorOccurred(GetError::ACCESS_DENIED);
|
||||||
files_.remove(uuid);
|
files_.remove(uuid);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
|
|
|
@ -44,8 +44,6 @@ PluginAdapter::PluginAdapter(LRCInstance* instance,
|
||||||
, pluginListModel_(new PluginListModel(instance, this))
|
, pluginListModel_(new PluginListModel(instance, this))
|
||||||
, lrcInstance_(instance)
|
, lrcInstance_(instance)
|
||||||
, settingsManager_(settingsManager)
|
, settingsManager_(settingsManager)
|
||||||
, tempPath_(QDir::tempPath())
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, pluginStoreListModel_, "PluginStoreListModel");
|
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, pluginStoreListModel_, "PluginStoreListModel");
|
||||||
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, pluginListModel_, "PluginListModel")
|
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, pluginListModel_, "PluginListModel")
|
||||||
|
|
|
@ -81,6 +81,5 @@ private:
|
||||||
LRCInstance* lrcInstance_;
|
LRCInstance* lrcInstance_;
|
||||||
AppSettingsManager* settingsManager_;
|
AppSettingsManager* settingsManager_;
|
||||||
std::mutex mtx_;
|
std::mutex mtx_;
|
||||||
QString tempPath_;
|
|
||||||
QString baseUrl_;
|
QString baseUrl_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,6 @@ public:
|
||||||
, parent_(parent)
|
, parent_(parent)
|
||||||
, settingsManager_(new AppSettingsManager(this))
|
, settingsManager_(new AppSettingsManager(this))
|
||||||
, lrcInstance_(instance)
|
, lrcInstance_(instance)
|
||||||
, tempPath_(QDir::tempPath())
|
|
||||||
, updateTimer_(new QTimer(this))
|
, updateTimer_(new QTimer(this))
|
||||||
{
|
{
|
||||||
connect(updateTimer_, &QTimer::timeout, this, [this] { checkForUpdates(); });
|
connect(updateTimer_, &QTimer::timeout, this, [this] { checkForUpdates(); });
|
||||||
|
@ -133,9 +132,9 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QThreadPool::globalInstance()->start([this, pluginId] {
|
QThreadPool::globalInstance()->start([this, pluginId] {
|
||||||
auto res = lrcInstance_->pluginModel().installPlugin(QDir(tempPath_).filePath(
|
auto res = lrcInstance_->pluginModel()
|
||||||
pluginId + ".jpl"),
|
.installPlugin(QDir(QDir::tempPath()).filePath(pluginId + ".jpl"),
|
||||||
true);
|
true);
|
||||||
if (res) {
|
if (res) {
|
||||||
parent_.versionStatusChanged(pluginId, PluginStatus::Role::INSTALLED);
|
parent_.versionStatusChanged(pluginId, PluginStatus::Role::INSTALLED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +143,7 @@ public:
|
||||||
});
|
});
|
||||||
parent_.versionStatusChanged(pluginId, PluginStatus::Role::INSTALLING);
|
parent_.versionStatusChanged(pluginId, PluginStatus::Role::INSTALLING);
|
||||||
},
|
},
|
||||||
tempPath_ + '/');
|
QDir::tempPath());
|
||||||
Q_EMIT parent_.versionStatusChanged(pluginId, PluginStatus::Role::DOWNLOADING);
|
Q_EMIT parent_.versionStatusChanged(pluginId, PluginStatus::Role::DOWNLOADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +160,6 @@ public:
|
||||||
PluginVersionManager& parent_;
|
PluginVersionManager& parent_;
|
||||||
AppSettingsManager* settingsManager_ {nullptr};
|
AppSettingsManager* settingsManager_ {nullptr};
|
||||||
LRCInstance* lrcInstance_ {nullptr};
|
LRCInstance* lrcInstance_ {nullptr};
|
||||||
QString tempPath_;
|
|
||||||
QTimer* updateTimer_;
|
QTimer* updateTimer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue