From 4cbcc855382a06088e2f016f62cafdbcb7e40665 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 20 Mar 2022 00:40:44 +0000 Subject: gentoo resync : 20.03.2022 --- ...top-5.23.5-attica-add-granular-cache-pref.patch | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 kde-plasma/plasma-desktop/files/plasma-desktop-5.23.5-attica-add-granular-cache-pref.patch (limited to 'kde-plasma/plasma-desktop/files') 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 +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 + -- cgit v1.2.3