Small fix for stale files getting stuck in the cache

This commit is contained in:
Petr Mrázek 2014-01-13 02:19:20 +01:00
parent 85ff1657fd
commit 4744ea07a8

View File

@ -58,11 +58,17 @@ void CacheDownload::start()
} }
QLOG_INFO() << "Downloading " << m_url.toString(); QLOG_INFO() << "Downloading " << m_url.toString();
QNetworkRequest request(m_url); QNetworkRequest request(m_url);
// check file consistency first.
QFile current(m_target_path);
if(current.exists() && current.size() != 0)
{
if (m_entry->remote_changed_timestamp.size()) if (m_entry->remote_changed_timestamp.size())
request.setRawHeader(QString("If-Modified-Since").toLatin1(), request.setRawHeader(QString("If-Modified-Since").toLatin1(),
m_entry->remote_changed_timestamp.toLatin1()); m_entry->remote_changed_timestamp.toLatin1());
if (m_entry->etag.size()) if (m_entry->etag.size())
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1()); request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
}
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)"); request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");