Skip to content
Snippets Groups Projects
Commit 6819d5f5 authored by akiraohgaki's avatar akiraohgaki
Browse files

UpdateHandler

parent d02e26d1
No related branches found
No related tags found
No related merge requests found
...@@ -24,8 +24,9 @@ void UpdateHandler::checkAll() ...@@ -24,8 +24,9 @@ void UpdateHandler::checkAll()
{ {
emit checkAllStarted(); emit checkAllStarted();
// Resets data
QJsonObject updateAvailableItems; QJsonObject updateAvailableItems;
configHandler_->setUsrConfigUpdateAvailableItems(updateAvailableItems); // Resets data configHandler_->setUsrConfigUpdateAvailableItems(updateAvailableItems);
auto installedItems = configHandler_->getUsrConfigInstalledItems(); auto installedItems = configHandler_->getUsrConfigInstalledItems();
...@@ -46,20 +47,28 @@ void UpdateHandler::checkAll() ...@@ -46,20 +47,28 @@ void UpdateHandler::checkAll()
file.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString() + "/" + filename); file.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString() + "/" + filename);
#endif #endif
QJsonObject updateAvailableItem; QString updateMethod = "";
if (installType == "bin") { if (installType == "bin") {
#ifdef QTLIB_UNIX #ifdef QTLIB_UNIX
if (file.path().endsWith(".appimage", Qt::CaseInsensitive)) { if (file.path().endsWith(".appimage", Qt::CaseInsensitive)) {
if (checkAppImage(file.path())) { if (checkAppImage(file.path())) {
updateAvailableItem["installed_item"] = itemKey; updateMethod = "appimageupdate";
updateAvailableItem["update_method"] = QString("appimageupdate");
configHandler_->setUsrConfigUpdateAvailableItemsItem(itemKey, updateAvailableItem);
} }
//else if (checkAppImageWithOcsApi(itemKey)) {} //else if (checkAppImageWithOcsApi(itemKey)) {
// updateMethod = "appimageupdatewithocsapi";
//}
} }
#endif #endif
} }
if (!updateMethod.isEmpty()) {
QJsonObject updateAvailableItem;
updateAvailableItem["installed_item"] = itemKey;
updateAvailableItem["update_method"] = updateMethod;
// Use installed item's key as unique key to the update available item
configHandler_->setUsrConfigUpdateAvailableItemsItem(itemKey, updateAvailableItem);
}
} }
auto application = configHandler_->getUsrConfigApplication(); auto application = configHandler_->getUsrConfigApplication();
...@@ -83,7 +92,9 @@ void UpdateHandler::update(const QString &itemKey) ...@@ -83,7 +92,9 @@ void UpdateHandler::update(const QString &itemKey)
if (updateMethod == "appimageupdate") { if (updateMethod == "appimageupdate") {
updateAppImage(itemKey); updateAppImage(itemKey);
} }
//else if (updateMethod == "appimageupdatewithocsapi") {} //else if (updateMethod == "appimageupdatewithocsapi") {
// updateAppImageWithOcsApi(itemKey);
//}
#endif #endif
} }
...@@ -111,16 +122,15 @@ bool UpdateHandler::checkAppImage(const QString &path) const ...@@ -111,16 +122,15 @@ bool UpdateHandler::checkAppImage(const QString &path) const
void UpdateHandler::updateAppImage(const QString &itemKey) void UpdateHandler::updateAppImage(const QString &itemKey)
{ {
auto installedItems = configHandler_->getUsrConfigInstalledItems();
auto updateAvailableItem = configHandler_->getUsrConfigUpdateAvailableItems()[itemKey].toObject(); auto updateAvailableItem = configHandler_->getUsrConfigUpdateAvailableItems()[itemKey].toObject();
auto installedItemKey = updateAvailableItem["installed_item"].toString(); auto installedItemKey = updateAvailableItem["installed_item"].toString();
auto installedItems = configHandler_->getUsrConfigInstalledItems();
if (!installedItems.contains(installedItemKey)) { if (!installedItems.contains(installedItemKey)) {
return; return;
} }
auto installedItem = installedItems[installedItemKey].toObject(); auto installedItem = installedItems[installedItemKey].toObject();
auto filename = installedItem["filename"].toString(); auto filename = installedItem["filename"].toString();
auto installType = installedItem["install_type"].toString(); auto installType = installedItem["install_type"].toString();
...@@ -136,6 +146,7 @@ void UpdateHandler::updateAppImage(const QString &itemKey) ...@@ -136,6 +146,7 @@ void UpdateHandler::updateAppImage(const QString &itemKey)
} }
appimage::update::Updater appImageUpdater(file.path().toStdString(), false); appimage::update::Updater appImageUpdater(file.path().toStdString(), false);
if (!appImageUpdater.start()) { if (!appImageUpdater.start()) {
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment