summaryrefslogtreecommitdiffstats
path: root/logic/net
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-13 02:19:20 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-13 02:19:20 +0100
commit4744ea07a892bc7066fbb21d394a2ce5efb0bdd9 (patch)
tree237304f43451c650c3a7334a5250f44967edea48 /logic/net
parent85ff1657fd3176d41d743613589e6cc79531376f (diff)
downloadMultiMC-4744ea07a892bc7066fbb21d394a2ce5efb0bdd9.tar
MultiMC-4744ea07a892bc7066fbb21d394a2ce5efb0bdd9.tar.gz
MultiMC-4744ea07a892bc7066fbb21d394a2ce5efb0bdd9.tar.lz
MultiMC-4744ea07a892bc7066fbb21d394a2ce5efb0bdd9.tar.xz
MultiMC-4744ea07a892bc7066fbb21d394a2ce5efb0bdd9.zip
Small fix for stale files getting stuck in the cache
Diffstat (limited to 'logic/net')
-rw-r--r--logic/net/CacheDownload.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp
index 8a8d00f0..0022c361 100644
--- a/logic/net/CacheDownload.cpp
+++ b/logic/net/CacheDownload.cpp
@@ -58,11 +58,17 @@ void CacheDownload::start()
}
QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url);
- 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());
+
+ // check file consistency first.
+ QFile current(m_target_path);
+ if(current.exists() && current.size() != 0)
+ {
+ 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)");