summaryrefslogtreecommitdiff
path: root/kde-plasma/plasma-desktop/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-03-20 00:40:44 +0000
committerV3n3RiX <venerix@koprulu.sector>2022-03-20 00:40:44 +0000
commit4cbcc855382a06088e2f016f62cafdbcb7e40665 (patch)
tree356496503d52354aa6d9f2d36126302fed5f3a73 /kde-plasma/plasma-desktop/files
parentfcc5224904648a8e6eb528d7603154160a20022f (diff)
gentoo resync : 20.03.2022
Diffstat (limited to 'kde-plasma/plasma-desktop/files')
-rw-r--r--kde-plasma/plasma-desktop/files/plasma-desktop-5.23.5-attica-add-granular-cache-pref.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/kde-plasma/plasma-desktop/files/plasma-desktop-5.23.5-attica-add-granular-cache-pref.patch b/kde-plasma/plasma-desktop/files/plasma-desktop-5.23.5-attica-add-granular-cache-pref.patch
new file mode 100644
index 000000000000..fb4d0bacbd90
--- /dev/null
+++ b/kde-plasma/plasma-desktop/files/plasma-desktop-5.23.5-attica-add-granular-cache-pref.patch
@@ -0,0 +1,57 @@
+From 346dafd3a0e19805f77147a9515a7333a05ed584 Mon Sep 17 00:00:00 2001
+From: Dan Leinir Turthra Jensen <admin@leinir.dk>
+Date: Tue, 8 Feb 2022 11:16:16 +0000
+Subject: [PATCH] Add a granular cache preference thing to attica-kde
+
+Commit 798027fd17ab86eea022e5d269aa86138b28b130
+
+This allows us to explicitly add cache preference to specific calls.
+Usually attica calls want to be very current, but in some cases we can
+assume things aren't going to change often (such as the categories
+call), and we can just use the cached version for those calls.
+
+Fix missing variable name
+Commit 8e164050c594855ee3728678d6d0907a10b28db6
+
+Only trust the expiration date if it's less than 24 hours
+Commit b85cf34298c274b5f16cb6c2aead7b87f0dabbb8
+
+Fix build
+Commit 6e8626f2d65a03af3cd12fb5390040c56ca3258d
+---
+ attica-kde/kdeplugin/kdeplatformdependent.cpp | 20 ++++++++++++++++++-
+ 1 file changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/attica-kde/kdeplugin/kdeplatformdependent.cpp b/attica-kde/kdeplugin/kdeplatformdependent.cpp
+index c2c90107e..850c91284 100644
+--- a/attica-kde/kdeplugin/kdeplatformdependent.cpp
++++ b/attica-kde/kdeplugin/kdeplatformdependent.cpp
+@@ -125,6 +125,25 @@ QNetworkRequest KdePlatformDependent::addOAuthToRequest(const QNetworkRequest &r
+ const QString bearer = bearer_format.arg(token);
+ notConstReq.setRawHeader("Authorization", bearer.toUtf8());
+ }
++
++ // Add cache preference in a granular fashion (we will almost certainly want more of these, but...)
++ static const QStringList preferCacheEndpoints{QLatin1String{"/content/categories"}};
++ for (const QString &endpoint : preferCacheEndpoints) {
++ if (notConstReq.url().toString().endsWith(endpoint)) {
++ QNetworkCacheMetaData cacheMeta{m_accessManager->cache()->metaData(notConstReq.url())};
++ if (cacheMeta.isValid()) {
++ // If the expiration date is valid, but longer than 24 hours, don't trust that things
++ // haven't changed and check first, otherwise just use the cached version to relieve
++ // server strain and reduce network traffic.
++ const QDateTime tomorrow{QDateTime::currentDateTime().addDays(1)};
++ if (cacheMeta.expirationDate().isValid() && cacheMeta.expirationDate() < tomorrow) {
++ notConstReq.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
++ }
++ }
++ break;
++ }
++ }
++
+ return notConstReq;
+ }
+
+--
+2.34.1
+