diff --git a/app/src/handlers/updatehandler.cpp b/app/src/handlers/updatehandler.cpp index b113253e5fc04184610213d76fec2dd297e8447f..0f73b05b41744154f95572426b6c3127ed511337 100644 --- a/app/src/handlers/updatehandler.cpp +++ b/app/src/handlers/updatehandler.cpp @@ -4,7 +4,6 @@ #include <QJsonValue> #include <QJsonArray> #include <QDateTime> -//#include <QThread> #include "qtlib_file.h" @@ -50,7 +49,7 @@ void UpdateHandler::checkAll() if (installType == "bin") { #ifdef QTLIB_UNIX if (filePath.endsWith(".appimage", Qt::CaseInsensitive)) { - if (AppImageUpdater(itemKey, filePath).checkAppImage()) { + if (AppImageUpdater(itemKey, filePath).checkForChanges()) { updateMethod = "appimageupdate"; } //else if (OcsFileUpdater(url).checkFile()) { @@ -152,15 +151,9 @@ void UpdateHandler::updateAppImage(const QString &itemKey) auto installType = installedItem["install_type"].toString(); auto filePath = configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString() + "/" + filename; - //auto *thread = new QThread(this); auto *updater = new AppImageUpdater(itemKey, filePath, this); - //updater->moveToThread(thread); - - //connect(thread, &QThread::started, updater, &AppImageUpdater::updateAppImage); connect(updater, &AppImageUpdater::updateProgress, this, &UpdateHandler::updateProgress); connect(updater, &AppImageUpdater::finished, this, &UpdateHandler::appImageUpdaterFinished); - //connect(updater, &AppImageUpdater::finished, thread, &QThread::quit); - //connect(thread, &QThread::finished, thread, &QThread::deleteLater); QJsonObject metadata; metadata["installed_item_key"] = installedItemKey; @@ -178,7 +171,6 @@ void UpdateHandler::updateAppImage(const QString &itemKey) metadataSet_[itemKey] = metadata; emit updateStarted(itemKey, true); - updater->updateAppImage(); - //thread->start(); + updater->start(); } #endif diff --git a/app/src/updaters/appimageupdater.cpp b/app/src/updaters/appimageupdater.cpp index 3f0d04b99e446f2fc988f0f84ee04d18de038284..d97defd7dbd39af08c3b864be8803a59e1e17477 100644 --- a/app/src/updaters/appimageupdater.cpp +++ b/app/src/updaters/appimageupdater.cpp @@ -44,14 +44,14 @@ QString AppImageUpdater::describeAppImage() const return QString::fromStdString(description); } -bool AppImageUpdater::checkAppImage() const +bool AppImageUpdater::checkForChanges() const { bool updateAvailable = false; updater_->checkForChanges(updateAvailable); return updateAvailable; } -void AppImageUpdater::updateAppImage() +void AppImageUpdater::start() { isFinishedWithNoError_ = false; errorString_ = ""; @@ -62,12 +62,12 @@ void AppImageUpdater::updateAppImage() } auto timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, &AppImageUpdater::checkUpdaterProgress); + connect(timer, &QTimer::timeout, this, &AppImageUpdater::checkProgress); connect(this, &AppImageUpdater::finished, timer, &QTimer::stop); timer->start(100); } -void AppImageUpdater::checkUpdaterProgress() +void AppImageUpdater::checkProgress() { if (!updater_->isDone()) { double progress; diff --git a/app/src/updaters/appimageupdater.h b/app/src/updaters/appimageupdater.h index 03477f72939b60b00f2b1527b6b89f689f032b61..beb2ac305d4cde0e44c8d6526f8f1da0855b773b 100644 --- a/app/src/updaters/appimageupdater.h +++ b/app/src/updaters/appimageupdater.h @@ -22,15 +22,15 @@ public: QString errorString() const; QString describeAppImage() const; - bool checkAppImage() const; - void updateAppImage(); + bool checkForChanges() const; + void start(); signals: void finished(AppImageUpdater *updater); void updateProgress(QString id, double progress); private slots: - void checkUpdaterProgress(); + void checkProgress(); private: QString id_;