[neon/kde/plasma-discover/Neon/release_jammy] debian/patches: Revert "emove patches applied in unstable."
Scarlett Moore
null at kde.org
Fri Apr 26 11:12:20 BST 2024
Git commit bf047213ffe00177eaa8062cc9e14877137c17b4 by Scarlett Moore.
Committed on 26/04/2024 at 10:12.
Pushed by scarlettmoore into branch 'Neon/release_jammy'.
Revert "emove patches applied in unstable."
This reverts commit 665e5dcb029b410c4dd1853fa6b2f95aba418b18.
A +3 -0 debian/patches/series
A +124 -0 debian/patches/upstream_cache_size_information.patch
A +78 -0 debian/patches/upstream_check_for_updates.patch
A +28 -0 debian/patches/upstream_place_refresh_request_upgradable.patch
https://invent.kde.org/neon/kde/plasma-discover/-/commit/bf047213ffe00177eaa8062cc9e14877137c17b4
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..ac20a0c
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,3 @@
+upstream_cache_size_information.patch
+upstream_check_for_updates.patch
+upstream_place_refresh_request_upgradable.patch
diff --git a/debian/patches/upstream_cache_size_information.patch b/debian/patches/upstream_cache_size_information.patch
new file mode 100644
index 0000000..4f17331
--- /dev/null
+++ b/debian/patches/upstream_cache_size_information.patch
@@ -0,0 +1,124 @@
+From 41040a1f085a8294e42321f684a55106038d6a45 Mon Sep 17 00:00:00 2001
+From: Kevin Ottens <kevin.ottens at enioka.com>
+Date: Thu, 4 Apr 2024 11:48:23 +0200
+Subject: [PATCH] snap: cache the size information in the SnapResource
+
+Depending where the latest QSnapdSnap object is coming from it might old
+or not a value for the download and installed sizes. To avoid loosing
+those between refreshSnap() calls we thus cache them in the SnapResource
+itself.
+---
+ .../backends/SnapBackend/SnapBackend.cpp | 1 +
+ .../backends/SnapBackend/SnapResource.cpp | 37 +++++++++++++++++--
+ .../backends/SnapBackend/SnapResource.h | 6 +++
+ 3 files changed, 40 insertions(+), 4 deletions(-)
+
+diff --git a/libdiscover/backends/SnapBackend/SnapBackend.cpp b/libdiscover/backends/SnapBackend/SnapBackend.cpp
+index 0e60bf4646..1b9e2857fb 100644
+--- a/libdiscover/backends/SnapBackend/SnapBackend.cpp
++++ b/libdiscover/backends/SnapBackend/SnapBackend.cpp
+@@ -270,6 +270,7 @@ void SnapBackend::refreshStates()
+ bool contained = kContains(resources, [res](const StreamResult &in) {
+ return in.resource == res;
+ });
++ res->updateSizes();
+ if (contained)
+ res->setState(AbstractResource::Installed);
+ else
+diff --git a/libdiscover/backends/SnapBackend/SnapResource.cpp b/libdiscover/backends/SnapBackend/SnapResource.cpp
+index b7c33835c0..007ea21b84 100644
+--- a/libdiscover/backends/SnapBackend/SnapResource.cpp
++++ b/libdiscover/backends/SnapBackend/SnapResource.cpp
+@@ -72,6 +72,8 @@ const QStringList SnapResource::s_topObjects({QStringLiteral("qrc:/qml/Permissio
+ SnapResource::SnapResource(QSharedPointer<QSnapdSnap> snap, AbstractResource::State state, SnapBackend *backend)
+ : AbstractResource(backend)
+ , m_state(state)
++ , m_installedSize(0)
++ , m_downloadSize(0)
+ , m_snap(snap)
+ {
+ setObjectName(snap->name());
+@@ -100,8 +102,11 @@ QString SnapResource::comment()
+
+ quint64 SnapResource::size()
+ {
+- // return isInstalled() ? m_snap->installedSize() : m_snap->downloadSize();
+- return m_snap->downloadSize();
++ if (m_state == AbstractResource::Installed) {
++ return installedSize();
++ } else {
++ return downloadSize();
++ }
+ }
+
+ QVariant SnapResource::icon() const
+@@ -298,9 +303,12 @@ void SnapResource::setSnap(const QSharedPointer<QSnapdSnap> &snap)
+ if (m_snap == snap)
+ return;
+
+- const bool newSize = m_snap->installedSize() != snap->installedSize() || m_snap->downloadSize() != snap->downloadSize();
++ const auto oldSize = size();
+ m_snap = snap;
+- if (newSize)
++ updateSizes();
++ const auto newSize = size();
++
++ if (newSize != oldSize)
+ Q_EMIT sizeChanged();
+
+ Q_EMIT newSnap();
+@@ -468,6 +476,27 @@ void SnapResource::setChannel(const QString &channelName)
+ #endif
+ }
+
++quint64 SnapResource::installedSize() const
++{
++ return m_installedSize;
++}
++
++quint64 SnapResource::downloadSize() const
++{
++ return m_downloadSize;
++}
++
++void SnapResource::updateSizes()
++{
++ if (m_snap->installedSize() > 0) {
++ m_installedSize = m_snap->installedSize();
++ }
++
++ if (m_snap->downloadSize() > 0) {
++ m_downloadSize = m_snap->downloadSize();
++ }
++}
++
+ void SnapResource::refreshSnap()
+ {
+ auto request = client()->find(QSnapdClient::FindFlag::MatchName, m_snap->name());
+diff --git a/libdiscover/backends/SnapBackend/SnapResource.h b/libdiscover/backends/SnapBackend/SnapResource.h
+index e7f4413edb..4f46036a34 100644
+--- a/libdiscover/backends/SnapBackend/SnapResource.h
++++ b/libdiscover/backends/SnapBackend/SnapResource.h
+@@ -68,6 +68,10 @@ public:
+ QString channel() const;
+ void setChannel(const QString &channel);
+
++ quint64 installedSize() const;
++ quint64 downloadSize() const;
++ void updateSizes();
++
+ QSharedPointer<QSnapdSnap> snap() const
+ {
+ return m_snap;
+@@ -82,6 +86,8 @@ public:
+ void refreshSnap();
+ void gotIcon();
+ AbstractResource::State m_state;
++ quint64 m_installedSize;
++ quint64 m_downloadSize;
+
+ QSharedPointer<QSnapdSnap> m_snap;
+ mutable QVariant m_icon;
+--
+GitLab
+
diff --git a/debian/patches/upstream_check_for_updates.patch b/debian/patches/upstream_check_for_updates.patch
new file mode 100644
index 0000000..fefa09b
--- /dev/null
+++ b/debian/patches/upstream_check_for_updates.patch
@@ -0,0 +1,78 @@
+From e5c32ebe81a489912eeab8c01de04506845bc144 Mon Sep 17 00:00:00 2001
+From: Kevin Ottens <kevin.ottens at enioka.com>
+Date: Thu, 4 Apr 2024 11:48:32 +0200
+Subject: [PATCH] snap: start checking for updates
+
+It indeed auto-updates by default but a) this is not instant, one might
+open Discover in between two auto-update attempts and b) snapd can be
+configured to disable auto-updates.
+
+Modify the backend to have a proper list of updates being reported in
+order to cover the two cases above.
+---
+ .../backends/SnapBackend/SnapBackend.cpp | 19 +++++++++++++++++++
+ .../backends/SnapBackend/SnapBackend.h | 4 +---
+ 2 files changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/libdiscover/backends/SnapBackend/SnapBackend.cpp b/libdiscover/backends/SnapBackend/SnapBackend.cpp
+index 1b9e2857fb..82e66a963e 100644
+--- a/libdiscover/backends/SnapBackend/SnapBackend.cpp
++++ b/libdiscover/backends/SnapBackend/SnapBackend.cpp
+@@ -84,6 +84,8 @@ SnapBackend::SnapBackend(QObject *parent)
+ , m_updater(new StandardBackendUpdater(this))
+ , m_reviews(OdrsReviewsBackend::global())
+ {
++ connect(m_updater, &StandardBackendUpdater::updatesCountChanged, this, &SnapBackend::updatesCountChanged);
++
+ connect(m_reviews.data(), &OdrsReviewsBackend::ratingsReady, this, [this] {
+ m_reviews->emitRatingFetched(this, kTransform<QList<AbstractResource *>>(m_resources.values(), [](AbstractResource *r) {
+ return r;
+@@ -257,6 +259,22 @@ Transaction *SnapBackend::removeApplication(AbstractResource *_app)
+ return new SnapTransaction(&m_client, app, Transaction::RemoveRole, AbstractResource::None);
+ }
+
++void SnapBackend::checkForUpdates()
++{
++ auto ret = new StoredResultsStream({populate(m_client.findRefreshable())});
++ connect(ret, &StoredResultsStream::finishedResources, this, [this](const QVector<StreamResult> &resources) {
++ for (SnapResource *res : std::as_const(m_resources)) {
++ bool contained = kContains(resources, [res](const StreamResult &in) {
++ return in.resource == res;
++ });
++ if (contained) {
++ res->setState(AbstractResource::Upgradeable);
++ res->updateSizes();
++ }
++ }
++ });
++}
++
+ QString SnapBackend::displayName() const
+ {
+ return QStringLiteral("Snap");
+@@ -276,6 +294,7 @@ void SnapBackend::refreshStates()
+ else
+ res->setState(AbstractResource::None);
+ }
++ checkForUpdates();
+ });
+ }
+
+diff --git a/libdiscover/backends/SnapBackend/SnapBackend.h b/libdiscover/backends/SnapBackend/SnapBackend.h
+index 8a9b6d3a65..7e2f885bb2 100644
+--- a/libdiscover/backends/SnapBackend/SnapBackend.h
++++ b/libdiscover/backends/SnapBackend/SnapBackend.h
+@@ -43,9 +43,7 @@ public:
+ {
+ return m_fetching;
+ }
+- void checkForUpdates() override
+- {
+- }
++ void checkForUpdates() override;
+ bool hasApplications() const override
+ {
+ return true;
+--
+GitLab
+
diff --git a/debian/patches/upstream_place_refresh_request_upgradable.patch b/debian/patches/upstream_place_refresh_request_upgradable.patch
new file mode 100644
index 0000000..1379786
--- /dev/null
+++ b/debian/patches/upstream_place_refresh_request_upgradable.patch
@@ -0,0 +1,28 @@
+From 03f3e05cae6484126410efef0f4e43310cb92e10 Mon Sep 17 00:00:00 2001
+From: Kevin Ottens <kevin.ottens at enioka.com>
+Date: Thu, 4 Apr 2024 15:04:49 +0200
+Subject: [PATCH] snap: place a refresh request for upgradeable packages
+
+This allows to manually upgrade snap packages as well.
+
+BUG: 476654
+---
+ libdiscover/backends/SnapBackend/SnapTransaction.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/libdiscover/backends/SnapBackend/SnapTransaction.cpp b/libdiscover/backends/SnapBackend/SnapTransaction.cpp
+index d1c1d7e39f..9d300f499e 100644
+--- a/libdiscover/backends/SnapBackend/SnapTransaction.cpp
++++ b/libdiscover/backends/SnapBackend/SnapTransaction.cpp
+@@ -24,6 +24,8 @@ SnapTransaction::SnapTransaction(QSnapdClient *client, SnapResource *app, Role r
+ {
+ if (role == RemoveRole)
+ setRequest(m_client->remove(app->packageName()));
++ else if (app->state() == AbstractResource::Upgradeable)
++ setRequest(m_client->refresh(app->packageName()));
+ else
+ setRequest(m_client->install(app->packageName()));
+ }
+--
+GitLab
+
More information about the Neon-commits
mailing list