From 451c683b661b9bf6103952bbeb8a118821d0b29b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= <tim@siosm.fr>
Date: Mon, 18 Mar 2024 14:32:38 +0100
Subject: [PATCH 1/2] rpm-ostree: Fix error paths in Transaction
Make sure that all error paths mark the transaction as completed before
returning.
---
.../backends/RpmOstreeBackend/RpmOstreeTransaction.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libdiscover/backends/RpmOstreeBackend/RpmOstreeTransaction.cpp b/libdiscover/backends/RpmOstreeBackend/RpmOstreeTransaction.cpp
index f021f7a0f..d3bd5ca47 100644
--- a/libdiscover/backends/RpmOstreeBackend/RpmOstreeTransaction.cpp
+++ b/libdiscover/backends/RpmOstreeBackend/RpmOstreeTransaction.cpp
@@ -211,6 +211,7 @@ void RpmOstreeTransaction::processCommand(int exitCode, QProcess::ExitStatus exi
const QJsonDocument jsonDocument = QJsonDocument::fromJson(m_stdout);
if (!jsonDocument.isObject()) {
qWarning() << "rpm-ostree-backend: Could not parse output as JSON:" << m_prog << m_args;
+ setStatus(Status::DoneWithErrorStatus);
return;
}
@@ -218,6 +219,7 @@ void RpmOstreeTransaction::processCommand(int exitCode, QProcess::ExitStatus exi
const QString newVersion = jsonDocument.object().value(QLatin1String("Labels")).toObject().value(QLatin1String("version")).toString();
if (newVersion.isEmpty()) {
qInfo() << "rpm-ostree-backend: Could not get the version from the container labels";
+ setStatus(Status::DoneWithErrorStatus);
return;
}
@@ -233,6 +235,8 @@ void RpmOstreeTransaction::processCommand(int exitCode, QProcess::ExitStatus exi
// Should never happen
qWarning() << "rpm-ostree-backend: Error: Unknown resource format. Please file a bug.";
passiveMessage(i18n("rpm-ostree-backend: Error: Unknown resource format. Please file a bug."));
+ setStatus(Status::DoneWithErrorStatus);
+ return;
}
// Always tell the backend to look for a new major version
@@ -259,6 +263,8 @@ void RpmOstreeTransaction::processCommand(int exitCode, QProcess::ExitStatus exi
// This should never happen
qWarning() << "rpm-ostree-backend: Error: Unknown operation requested. Please file a bug.";
passiveMessage(i18n("rpm-ostree-backend: Error: Unknown operation requested. Please file a bug."));
+ setStatus(Status::DoneWithErrorStatus);
+ return;
}
setStatus(Status::DoneStatus);
}
--
2.44.0