aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Ribbers <bribbers@disroot.org>2022-02-19 11:05:28 +0100
committerBart Ribbers <bribbers@disroot.org>2022-02-19 11:05:29 +0100
commitb5c29c7257a758b4411266fc1e63725c4448654b (patch)
treef58321a5ceae7b50430c2b583f2df0e82aefc78d
parent05357dbca927b3206f0906fdc9ec592b47caae59 (diff)
community/knewstuff: backport upstream requested patch
Mitigates load issues they are having on their services
-rw-r--r--community/knewstuff/0001-Engine-Ensure-we-are-not-using-the-wrong-ProvidersUrl.patch27
-rw-r--r--community/knewstuff/0002-Add-conditional-cache-preference-to-http-requests.patch62
-rw-r--r--community/knewstuff/APKBUILD9
3 files changed, 96 insertions, 2 deletions
diff --git a/community/knewstuff/0001-Engine-Ensure-we-are-not-using-the-wrong-ProvidersUrl.patch b/community/knewstuff/0001-Engine-Ensure-we-are-not-using-the-wrong-ProvidersUrl.patch
new file mode 100644
index 00000000000..130ca3dfbd5
--- /dev/null
+++ b/community/knewstuff/0001-Engine-Ensure-we-are-not-using-the-wrong-ProvidersUrl.patch
@@ -0,0 +1,27 @@
+From c8165b7a0d622e318b3353ccf257a8f229dd12c9 Mon Sep 17 00:00:00 2001
+From: Aleix Pol <aleixpol@kde.org>
+Date: Tue, 8 Feb 2022 11:48:11 +0100
+Subject: [PATCH] Engine: Ensure we are not using the wrong ProvidersUrl
+
+---
+ src/core/engine.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+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();
+--
+GitLab
+
diff --git a/community/knewstuff/0002-Add-conditional-cache-preference-to-http-requests.patch b/community/knewstuff/0002-Add-conditional-cache-preference-to-http-requests.patch
new file mode 100644
index 00000000000..94a709e7bf9
--- /dev/null
+++ b/community/knewstuff/0002-Add-conditional-cache-preference-to-http-requests.patch
@@ -0,0 +1,62 @@
+From e1c6f2bf383876a31cd3e3f9e6edcaa19dc0a7dd Mon Sep 17 00:00:00 2001
+From: Dan Leinir Turthra Jensen <admin@leinir.dk>
+Date: Wed, 9 Feb 2022 16:17:58 +0000
+Subject: [PATCH] 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
+---
+ src/core/jobs/httpworker.cpp | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/src/core/jobs/httpworker.cpp b/src/core/jobs/httpworker.cpp
+index b81edd2d..3629ff79 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;
+ };
+
+@@ -102,6 +101,18 @@ static void addUserAgent(QNetworkRequest &request)
+ agentHeader += QStringLiteral("-%1/%2").arg(QCoreApplication::instance()->applicationName(), QCoreApplication::instance()->applicationVersion());
+ }
+ request.setHeader(QNetworkRequest::UserAgentHeader, agentHeader);
++
++ // 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()
+--
+GitLab
+
diff --git a/community/knewstuff/APKBUILD b/community/knewstuff/APKBUILD
index b247746942f..cae384530b8 100644
--- a/community/knewstuff/APKBUILD
+++ b/community/knewstuff/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=knewstuff
pkgver=5.88.0
-pkgrel=0
+pkgrel=1
pkgdesc="Framework for downloading and sharing additional application data"
# armhf blocked by qt5-qtdeclarative
# mips64, s390x and riscv64 blocked by polkit
@@ -33,7 +33,10 @@ makedepends="$depends_dev
qt5-qttools-dev
"
checkdepends="xvfb-run"
-source="https://download.kde.org/stable/frameworks/${pkgver%.*}/knewstuff-$pkgver.tar.xz"
+source="https://download.kde.org/stable/frameworks/${pkgver%.*}/knewstuff-$pkgver.tar.xz
+ 0001-Engine-Ensure-we-are-not-using-the-wrong-ProvidersUrl.patch
+ 0002-Add-conditional-cache-preference-to-http-requests.patch
+ "
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
build() {
@@ -55,4 +58,6 @@ package() {
}
sha512sums="
253f2d5b5fb496a0d24674592b7f6d69866422ffb393bf1db738799f4846e109c8e30e55eff57c6b7c3c56f1e43fa126ba396b8680524a40eec018b84443e634 knewstuff-5.88.0.tar.xz
+e45c22952c87234b25915b7039e2e4cca1c920d6fea32ed29a93c6f45940b6a1b09f8d38bba929f55bbdd63d868327436f83b107808e62c6a45f405f90a09324 0001-Engine-Ensure-we-are-not-using-the-wrong-ProvidersUrl.patch
+c10d388c063ac7c5b0a346829228e817cd424b972fc70d533486815767fe1cb31d031e8c8e9f2767798beff1c1db36520bb586948842ed1abdd7ba29bf3f57b4 0002-Add-conditional-cache-preference-to-http-requests.patch
"