[plasma/discover/Plasma/6.1] libdiscover/backends/FlatpakBackend: flatpak: uninstall properly EOL refs that have no replacement
Harald Sitter
null at kde.org
Fri Jul 12 08:55:07 BST 2024
Git commit 510816d9cb6dc573696eba6304f8a77512719c6c by Harald Sitter.
Committed on 12/07/2024 at 07:10.
Pushed by sitter into branch 'Plasma/6.1'.
flatpak: uninstall properly EOL refs that have no replacement
same logic as already existed but simply uninstalling if the user
acknowledges
(cherry picked from commit 6d0c3c63e65fbb8e2cb52ae2ecc02715605701ab)
This adds new strings that cannot be avoided since we forgot to handle an entire use case
CCMAIL: kde-i18n-doc at kde.org
M +37 -10 libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.cpp
https://invent.kde.org/plasma/discover/-/commit/510816d9cb6dc573696eba6304f8a77512719c6c
diff --git a/libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.cpp b/libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.cpp
index 82aa6207fe..012bafe4e9 100644
--- a/libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.cpp
+++ b/libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.cpp
@@ -397,18 +397,37 @@ bool FlatpakTransactionThread::end_of_lifed_with_rebase(const char *remote,
{
QMutexLocker lock(&m_proceedMutex);
+ enum class Execute { Rebase, Uninstall };
+ auto target = Execute::Rebase;
+ if (!rebased_to_ref) { // ref has no replacement -> uninstall
+ target = Execute::Uninstall;
+ }
+
if (QString::fromUtf8(rebased_to_ref).startsWith("runtime/"_L1)) {
qCDebug(LIBDISCOVER_BACKEND_FLATPAK_LOG) << "Automatically transitioning runtime";
m_proceed = true;
} else {
m_proceed = false;
- Q_EMIT proceedRequest(
- i18nc("@title", "Replacement Available"),
- xi18nc(
- "@info %1 and 2 are flatpak ids e.g. org.kde.krita (can be rather lengthy though)",
- "<resource>%1</resource> is no longer receiving updates.<nl/><nl/>Replace it with the supported version provided by <resource>%2</resource>?",
- QString::fromUtf8(ref),
- QString::fromUtf8(rebased_to_ref)));
+
+ switch (target) {
+ case Execute::Rebase:
+ Q_EMIT proceedRequest(i18nc("@title", "Replacement Available"),
+ xi18nc("@info %1 and 2 are flatpak ids e.g. org.kde.krita (can be rather lengthy though)",
+ "<resource>%1</resource> is no longer receiving updates.<nl/><nl/>Replace it with the supported version provided by "
+ "<resource>%2</resource>?",
+ QString::fromUtf8(ref),
+ QString::fromUtf8(rebased_to_ref)));
+ break;
+ case Execute::Uninstall:
+ Q_EMIT proceedRequest(i18nc("@title", "Automatic Removal"),
+ xi18nc("@info %1 is a flatpak id e.g. org.kde.krita (can be rather lengthy though)",
+ "<resource>%1</resource> is no longer receiving updates.<nl/><p>The reason given is: "
+ "<message>%2</message></p><nl/><p>Automatically remove it?</p>",
+ QString::fromUtf8(ref),
+ QString::fromUtf8(reason)));
+ break;
+ }
+
m_proceedCondition.wait(&m_proceedMutex);
}
@@ -417,12 +436,20 @@ bool FlatpakTransactionThread::end_of_lifed_with_rebase(const char *remote,
}
GError *localError = nullptr;
+ auto correct = false;
+ switch (target) {
+ case Execute::Rebase:
#if FLATPAK_CHECK_VERSION(1, 15, 0)
- const auto correct = flatpak_transaction_add_rebase_and_uninstall(m_transaction, remote, rebased_to_ref, ref, nullptr, previous_ids, &localError);
+ correct = flatpak_transaction_add_rebase_and_uninstall(m_transaction, remote, rebased_to_ref, ref, nullptr, previous_ids, &localError);
#else
- const auto correct = flatpak_transaction_add_rebase(m_transaction, remote, rebased_to_ref, nullptr, previous_ids, &localError)
- && flatpak_transaction_add_uninstall(m_transaction, ref, &localError);
+ correct = flatpak_transaction_add_rebase(m_transaction, remote, rebased_to_ref, nullptr, previous_ids, &localError)
+ && flatpak_transaction_add_uninstall(m_transaction, ref, &localError);
#endif
+ break;
+ case Execute::Uninstall:
+ correct = flatpak_transaction_add_uninstall(m_transaction, ref, &localError);
+ break;
+ }
if (!correct || localError) {
fail(ref, localError);
return false;
More information about the kde-i18n-doc
mailing list