summaryrefslogtreecommitdiffstats
path: root/logic/net/CacheDownload.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-10-18 01:00:46 +0200
committerPetr Mrázek <peterix@gmail.com>2013-10-18 01:00:46 +0200
commit205570be32b5cbd40eeb2b7e2d8d4fe116b07f64 (patch)
tree7af19a7479ae0c1dbef4d9cbc65c5550f9a3adc1 /logic/net/CacheDownload.cpp
parenta600286e33601a85949b9e51bd5421a45f9998ac (diff)
downloadMultiMC-205570be32b5cbd40eeb2b7e2d8d4fe116b07f64.tar
MultiMC-205570be32b5cbd40eeb2b7e2d8d4fe116b07f64.tar.gz
MultiMC-205570be32b5cbd40eeb2b7e2d8d4fe116b07f64.tar.lz
MultiMC-205570be32b5cbd40eeb2b7e2d8d4fe116b07f64.tar.xz
MultiMC-205570be32b5cbd40eeb2b7e2d8d4fe116b07f64.zip
Support version format 9, fix version-related segfault, (maybe) fix forge lists.
Diffstat (limited to 'logic/net/CacheDownload.cpp')
-rw-r--r--logic/net/CacheDownload.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp
index 6a76a4ae..309eb345 100644
--- a/logic/net/CacheDownload.cpp
+++ b/logic/net/CacheDownload.cpp
@@ -33,7 +33,11 @@ void CacheDownload::start()
}
QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
- request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
+ if(m_entry->remote_changed_timestamp.size())
+ request.setRawHeader(QString("If-Modified-Since").toLatin1(), m_entry->remote_changed_timestamp.toLatin1());
+ if(m_entry->etag.size())
+ request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
+
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
auto worker = MMC->qnam();
@@ -87,7 +91,11 @@ void CacheDownload::downloadFinished()
QFileInfo output_file_info(m_target_path);
m_entry->etag = m_reply->rawHeader("ETag").constData();
- m_entry->last_changed_timestamp =
+ if(m_reply->hasRawHeader("Last-Modified"))
+ {
+ m_entry->remote_changed_timestamp = m_reply->rawHeader("Last-Modified").constData();
+ }
+ m_entry->local_changed_timestamp =
output_file_info.lastModified().toUTC().toMSecsSinceEpoch();
m_entry->stale = false;
MMC->metacache()->updateEntry(m_entry);