mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:41:02 +02:00
Don't refresh if no lastModified tag in http request
This commit is contained in:
parent
691b078efc
commit
405301f861
1 changed files with 13 additions and 0 deletions
|
@ -332,6 +332,10 @@ void Resource::maybeRefresh() {
|
||||||
// We don't need to update, return
|
// We don't need to update, return
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (!variant.isValid() || !variant.canConvert<QDateTime>() ||
|
||||||
|
!variant.value<QDateTime>().isValid() || variant.value<QDateTime>().isNull()) {
|
||||||
|
qDebug() << "Cannot determine when" << _url.fileName() << "was modified last, cached version might be outdated";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Loaded" << _url.fileName() << "from the disk cache but the network version is newer, refreshing.";
|
qDebug() << "Loaded" << _url.fileName() << "from the disk cache but the network version is newer, refreshing.";
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -355,10 +359,19 @@ void Resource::makeRequest() {
|
||||||
} else {
|
} else {
|
||||||
if (Q_LIKELY(NetworkAccessManager::getInstance().cache())) {
|
if (Q_LIKELY(NetworkAccessManager::getInstance().cache())) {
|
||||||
QNetworkCacheMetaData metaData = NetworkAccessManager::getInstance().cache()->metaData(_url);
|
QNetworkCacheMetaData metaData = NetworkAccessManager::getInstance().cache()->metaData(_url);
|
||||||
|
bool needUpdate = false;
|
||||||
if (metaData.expirationDate().isNull() || metaData.expirationDate() <= QDateTime::currentDateTime()) {
|
if (metaData.expirationDate().isNull() || metaData.expirationDate() <= QDateTime::currentDateTime()) {
|
||||||
// If the expiration date is NULL or in the past,
|
// If the expiration date is NULL or in the past,
|
||||||
// put one far enough away that it won't be an issue.
|
// put one far enough away that it won't be an issue.
|
||||||
metaData.setExpirationDate(QDateTime::currentDateTime().addYears(100));
|
metaData.setExpirationDate(QDateTime::currentDateTime().addYears(100));
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (metaData.lastModified().isNull()) {
|
||||||
|
// If the lastModified date is NULL, set it to now.
|
||||||
|
metaData.setLastModified(QDateTime::currentDateTime());
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
if (needUpdate) {
|
||||||
NetworkAccessManager::getInstance().cache()->updateMetaData(metaData);
|
NetworkAccessManager::getInstance().cache()->updateMetaData(metaData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue