[neon/kde/knewstuff/Neon/release] debian/patches: patches recommended by maintainers

Jonathan Esk-Riddell null at kde.org
Tue Mar 1 11:30:44 GMT 2022


Git commit 796c6a61b64f2c6a45ec05d0444de8e625ad8fdd by Jonathan Esk-Riddell.
Committed on 01/03/2022 at 11:30.
Pushed by jriddell into branch 'Neon/release'.

patches recommended by maintainers

A  +56   -0    debian/patches/cache.diff
A  +21   -0    debian/patches/prividersurl.diff
A  +1    -0    debian/patches/series

https://invent.kde.org/neon/kde/knewstuff/commit/796c6a61b64f2c6a45ec05d0444de8e625ad8fdd

diff --git a/debian/patches/cache.diff b/debian/patches/cache.diff
new file mode 100644
index 0000000..5aebd32
--- /dev/null
+++ b/debian/patches/cache.diff
@@ -0,0 +1,56 @@
+commit e1c6f2bf383876a31cd3e3f9e6edcaa19dc0a7dd
+Author: Dan Leinir Turthra Jensen <admin at leinir.dk>
+Date:   Wed Feb 9 16:17:58 2022 +0000
+
+    Add conditional cache preference to http requests
+    
+    If we have a cache that's older than 7 days, assume that it's out of
+    date and actually try again. If it's younger than that, assume that it's
+    just the same, and prefer our cached version, if we have one.
+    
+    The logic here is an attempt at striking a balance between using our cache
+    to its fullest potential (as in, reducing server-side load and network
+    roundtrips in general) while also handling the situation where the
+    information that we are fed about the cache is not entirely correct (such
+    as the case where we're told there's no expiration date, but the data in
+    fact does change). 7 days seems a sensible sort of deadline for that,
+    though we could change that later if we need to.
+    
+    This was born out of a discussion on another kns review[1]
+    
+    Assume that no cache expiration time will be longer than 7 days, but otherwise prefer the cache
+    This is mildly hacky, but if we don't do this, we end up with infinite cache expirations in some
+    cases, which of course isn't really acceptable... See ed62ee20 for a situation where that happened.
+    
+    [1] https://invent.kde.org/frameworks/knewstuff/-/merge_requests/166#note_394067
+
+diff --git a/src/core/jobs/httpworker.cpp b/src/core/jobs/httpworker.cpp
+index b52161f6..208e1ef0 100644
+--- a/src/core/jobs/httpworker.cpp
++++ b/src/core/jobs/httpworker.cpp
+@@ -41,7 +41,6 @@ public:
+         return nam.get(request);
+     }
+ 
+-private:
+     QNetworkDiskCache cache;
+ };
+ 
+@@ -101,6 +100,17 @@ static void addUserAgent(QNetworkRequest &request)
+     request.setHeader(QNetworkRequest::UserAgentHeader, agentHeader);
+     // If the remote supports HTTP/2, then we should definitely be using that
+     request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
++
++    // Assume that no cache expiration time will be longer than a week, but otherwise prefer the cache
++    // This is mildly hacky, but if we don't do this, we end up with infinite cache expirations in some
++    // cases, which of course isn't really acceptable... See ed62ee20 for a situation where that happened.
++    QNetworkCacheMetaData cacheMeta{s_httpWorkerNAM->cache.metaData(request.url())};
++    if (cacheMeta.isValid()) {
++        const QDateTime nextWeek{QDateTime::currentDateTime().addDays(7)};
++        if (cacheMeta.expirationDate().isValid() && cacheMeta.expirationDate() < nextWeek) {
++            request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
++        }
++    }
+ }
+ 
+ void HTTPWorker::startRequest()
diff --git a/debian/patches/prividersurl.diff b/debian/patches/prividersurl.diff
new file mode 100644
index 0000000..8d0d803
--- /dev/null
+++ b/debian/patches/prividersurl.diff
@@ -0,0 +1,21 @@
+commit c8165b7a0d622e318b3353ccf257a8f229dd12c9
+Author: Aleix Pol <aleixpol at kde.org>
+Date:   Tue Feb 8 11:48:11 2022 +0100
+
+    Engine: Ensure we are not using the wrong ProvidersUrl
+
+diff --git a/src/core/engine.cpp b/src/core/engine.cpp
+index 139dda1a..c96ba890 100644
+--- a/src/core/engine.cpp
++++ b/src/core/engine.cpp
+@@ -264,6 +264,10 @@ bool Engine::init(const QString &configfile)
+     Q_EMIT uploadEnabledChanged();
+ 
+     m_providerFileUrl = group.readEntry("ProvidersUrl");
++    if (m_providerFileUrl == QLatin1String("https://download.kde.org/ocs/providers.xml")) {
++        m_providerFileUrl = QStringLiteral("https://autoconfig.kde.org/ocs/providers.xml");
++        qCWarning(KNEWSTUFFCORE) << "Please make sure" << configfile << "has ProvidersUrl=https://autoconfig.kde.org/ocs/providers.xml";
++    }
+     if (group.readEntry("UseLocalProvidersFile", "false").toLower() == QLatin1String{"true"}) {
+         // The local providers file is called "appname.providers", to match "appname.knsrc"
+         m_providerFileUrl = QUrl::fromLocalFile(QLatin1String("%1.providers").arg(configFullPath.left(configFullPath.length() - 6))).toString();
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..bc3451c
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+cache.diff prividersurl.diff


More information about the Neon-commits mailing list