summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base/httpget.cpp
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 /rbutil/rbutilqt/base/httpget.cpp
parent96adddaab3090dabdeede004d2d0de0468b04090 (diff)
downloadrockbox-0fcc84f46370f972059860bd19c61de9926ee29d.tar.gz
rockbox-0fcc84f46370f972059860bd19c61de9926ee29d.tar.bz2
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
Diffstat (limited to 'rbutil/rbutilqt/base/httpget.cpp')
-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)
void HttpGet::getFileFinish()
{
m_cachefile = m_cachedir.absolutePath() + "/rbutil-cache/" + m_hash;
+ QString indexFile = m_cachedir.absolutePath() + "/rbutil-cache/cache.txt";
if(m_usecache) {
// check if the file is present in cache
QFileInfo cachefile = QFileInfo(m_cachefile);
@@ -279,6 +280,23 @@ void HttpGet::getFileFinish()
<< cachefile.lastModified();
}
qDebug() << "[HTTP] Cache: caching as" << m_cachefile;
+ // update cache index file
+ QFile idxFile(indexFile);
+ idxFile.open(QIODevice::ReadOnly);
+ QByteArray currLine;
+ do {
+ QByteArray currLine = idxFile.readLine(1000);
+ if(currLine.startsWith(m_hash.toUtf8()))
+ break;
+ } while(!currLine.isEmpty());
+ idxFile.close();
+ if(currLine.isEmpty()) {
+ idxFile.open(QIODevice::Append);
+ QString outline = m_hash + "\t" + m_header.value("Host") + "\t"
+ + m_path + "\t" + m_query + "\n";
+ idxFile.write(outline.toUtf8());
+ idxFile.close();
+ }
}
}