diff --git a/src/ui/manager/autoupdatemanager.cpp b/src/ui/manager/autoupdatemanager.cpp index eb3d9c00..9fbbb72a 100644 --- a/src/ui/manager/autoupdatemanager.cpp +++ b/src/ui/manager/autoupdatemanager.cpp @@ -28,7 +28,7 @@ void AutoUpdateManager::setFlags(Flags v) { if (m_flags != v) { m_flags = v; - emit flagsChanged(v); + emit flagsChanged(); } } @@ -39,6 +39,14 @@ void AutoUpdateManager::setFlag(Flag v, bool on) setFlags(flags); } +void AutoUpdateManager::setFileName(const QString &v) +{ + if (m_fileName != v) { + m_fileName = v; + emit fileNameChanged(); + } +} + int AutoUpdateManager::bytesReceived() const { return downloader() ? downloader()->buffer().size() : m_downloadSize; @@ -119,7 +127,7 @@ void AutoUpdateManager::setupByTaskInfo(TaskInfoUpdateChecker *taskInfo) const QFileInfo fi(installerPath()); const bool downloaded = (fi.exists() && fi.size() == m_downloadSize); - qCDebug(LC) << "Check download:" << taskInfo->version() << "downloaded:" << downloaded; + qCDebug(LC) << "Check:" << taskInfo->version() << "downloaded:" << downloaded; setIsDownloaded(downloaded); } @@ -157,8 +165,10 @@ bool AutoUpdateManager::runInstaller() const QString installerPath = this->installerPath(); const QStringList args = installerArgs(settings); - if (!QProcess::startDetached(installerPath, args)) + if (!QProcess::startDetached(installerPath, args)) { + qCDebug(LC) << "Run Installer error:" << installerPath << args; return false; + } if (settings->hasService()) { emit restartClients(installerPath); diff --git a/src/ui/manager/autoupdatemanager.h b/src/ui/manager/autoupdatemanager.h index ee4e024b..233ad5f7 100644 --- a/src/ui/manager/autoupdatemanager.h +++ b/src/ui/manager/autoupdatemanager.h @@ -40,6 +40,9 @@ public: bool isDownloading() const { return testFlag(IsDownloading); } void setIsDownloading(bool on) { setFlag(IsDownloading, on); } + QString fileName() const { return m_fileName; } + void setFileName(const QString &v); + virtual int bytesReceived() const; void setUp() override; @@ -51,8 +54,9 @@ public slots: bool runInstaller(); signals: - void flagsChanged(AutoUpdateManager::Flags flags); + void flagsChanged(); void bytesReceivedChanged(int size); + void fileNameChanged(); void restartClients(const QString &installerPath); @@ -61,6 +65,8 @@ protected: void setupDownloader() override; + QString installerPath() const { return m_updatePath + m_fileName; } + protected slots: void downloadFinished(const QByteArray &data, bool success) override; @@ -71,8 +77,6 @@ private: bool saveInstaller(const QByteArray &fileData); - QString installerPath() const { return m_updatePath + m_fileName; } - static QStringList installerArgs(FortSettings *settings); private: diff --git a/src/ui/rpc/autoupdatemanagerrpc.cpp b/src/ui/rpc/autoupdatemanagerrpc.cpp index c3caa388..7c45dad9 100644 --- a/src/ui/rpc/autoupdatemanagerrpc.cpp +++ b/src/ui/rpc/autoupdatemanagerrpc.cpp @@ -11,8 +11,8 @@ inline bool processAutoUpdateManager_updateState( AutoUpdateManager *autoUpdateManager, const ProcessCommandArgs &p) { if (auto aum = qobject_cast(autoUpdateManager)) { - aum->updateState( - AutoUpdateManager::Flags(p.args.value(0).toInt()), p.args.value(1).toInt()); + aum->updateState(AutoUpdateManager::Flags(p.args.value(0).toInt()), p.args.value(1).toInt(), + p.args.value(2).toString()); } return true; } @@ -68,10 +68,12 @@ void AutoUpdateManagerRpc::setBytesReceived(int v) } } -void AutoUpdateManagerRpc::updateState(AutoUpdateManager::Flags flags, int bytesReceived) +void AutoUpdateManagerRpc::updateState( + AutoUpdateManager::Flags flags, int bytesReceived, const QString &fileName) { setFlags(flags); setBytesReceived(bytesReceived); + setFileName(fileName); } QVariantList AutoUpdateManagerRpc::updateState_args() @@ -80,8 +82,9 @@ QVariantList AutoUpdateManagerRpc::updateState_args() const auto flags = autoUpdateManager->flags(); const auto bytesReceived = autoUpdateManager->bytesReceived(); + const auto fileName = autoUpdateManager->fileName(); - return { int(flags), bytesReceived }; + return { int(flags), bytesReceived, fileName }; } bool AutoUpdateManagerRpc::processInitClient(ControlWorker *w) diff --git a/src/ui/rpc/autoupdatemanagerrpc.h b/src/ui/rpc/autoupdatemanagerrpc.h index 7ed53400..55ad3837 100644 --- a/src/ui/rpc/autoupdatemanagerrpc.h +++ b/src/ui/rpc/autoupdatemanagerrpc.h @@ -18,7 +18,7 @@ public: int bytesReceived() const override { return m_bytesReceived; } void setBytesReceived(int v); - void updateState(AutoUpdateManager::Flags flags, int bytesReceived); + void updateState(AutoUpdateManager::Flags flags, int bytesReceived, const QString &fileName); static QVariantList updateState_args();