summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-10-14 20:21:23 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-10-14 20:21:23 +0000
commit0fcc84f46370f972059860bd19c61de9926ee29d (patch)
treecc32577d2c4325268f672939aa016efa30dcb228
parent96adddaab3090dabdeede004d2d0de0468b04090 (diff)
downloadrockbox-0fcc84f46370f972059860bd19c61de9926ee29d.tar.gz
rockbox-0fcc84f46370f972059860bd19c61de9926ee29d.zip
Add cache index file to HttpGet class to maintain a list of hash - file origin mappings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23174 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/base/httpget.cpp18
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)
240void HttpGet::getFileFinish() 240void 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 }