diff options
Diffstat (limited to 'rbutil/rbutilqt/base/httpget.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/httpget.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/httpget.cpp b/rbutil/rbutilqt/base/httpget.cpp index e808a6381d..a412cdf7d0 100644 --- a/rbutil/rbutilqt/base/httpget.cpp +++ b/rbutil/rbutilqt/base/httpget.cpp | |||
@@ -240,6 +240,7 @@ bool HttpGet::getFile(const QUrl &url) | |||
240 | void HttpGet::getFileFinish() | 240 | void HttpGet::getFileFinish() |
241 | { | 241 | { |
242 | m_cachefile = m_cachedir.absolutePath() + "/rbutil-cache/" + m_hash; | 242 | m_cachefile = m_cachedir.absolutePath() + "/rbutil-cache/" + m_hash; |
243 | QString indexFile = m_cachedir.absolutePath() + "/rbutil-cache/cache.txt"; | ||
243 | if(m_usecache) { | 244 | if(m_usecache) { |
244 | // check if the file is present in cache | 245 | // check if the file is present in cache |
245 | QFileInfo cachefile = QFileInfo(m_cachefile); | 246 | QFileInfo cachefile = QFileInfo(m_cachefile); |
@@ -279,6 +280,23 @@ void HttpGet::getFileFinish() | |||
279 | << cachefile.lastModified(); | 280 | << cachefile.lastModified(); |
280 | } | 281 | } |
281 | qDebug() << "[HTTP] Cache: caching as" << m_cachefile; | 282 | qDebug() << "[HTTP] Cache: caching as" << m_cachefile; |
283 | // update cache index file | ||
284 | QFile idxFile(indexFile); | ||
285 | idxFile.open(QIODevice::ReadOnly); | ||
286 | QByteArray currLine; | ||
287 | do { | ||
288 | QByteArray currLine = idxFile.readLine(1000); | ||
289 | if(currLine.startsWith(m_hash.toUtf8())) | ||
290 | break; | ||
291 | } while(!currLine.isEmpty()); | ||
292 | idxFile.close(); | ||
293 | if(currLine.isEmpty()) { | ||
294 | idxFile.open(QIODevice::Append); | ||
295 | QString outline = m_hash + "\t" + m_header.value("Host") + "\t" | ||
296 | + m_path + "\t" + m_query + "\n"; | ||
297 | idxFile.write(outline.toUtf8()); | ||
298 | idxFile.close(); | ||
299 | } | ||
282 | } | 300 | } |
283 | 301 | ||
284 | } | 302 | } |