Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Desktop
Commits
b85cf342
Commit
b85cf342
authored
Feb 09, 2022
by
Dan Leinir Turthra Jensen
🌈
Browse files
Only trust the expiration date if it's less than 24 hours
parent
8e164050
Pipeline
#135444
passed with stage
in 2 minutes and 48 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
attica-kde/kdeplugin/kdeplatformdependent.cpp
View file @
b85cf342
...
...
@@ -133,7 +133,16 @@ QNetworkRequest KdePlatformDependent::addOAuthToRequest(const QNetworkRequest &r
}
for
(
const
QString
&
endpoint
:
preferCacheEndpoints
)
{
if
(
notConstReq
.
url
().
endsWith
(
endpoint
))
{
notConstReq
.
setAttribute
(
QNetworkRequest
::
CacheLoadControlAttribute
,
QNetworkRequest
::
PreferCache
);
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
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment