diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-04-06 17:20:13 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-04-06 17:20:13 +0000 |
commit | 2bcc5f782dc9199da7ebfa8f661f673eb6c3de65 (patch) | |
tree | 232520a226f8bfc38b8e0366de74c0d242337103 | |
parent | f75d409346da1253320864a8af53b26f069dea74 (diff) |
make sure cachefolder is existent when enabling it using setCache(bool). Fixes cache not working properly if the cache folder didn't exist.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16991 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/rbutilqt/httpget.cpp | 31 | ||||
-rw-r--r-- | rbutil/rbutilqt/httpget.h | 1 |
2 files changed, 23 insertions, 9 deletions
diff --git a/rbutil/rbutilqt/httpget.cpp b/rbutil/rbutilqt/httpget.cpp index c1e541391b..e3742480ab 100644 --- a/rbutil/rbutilqt/httpget.cpp +++ b/rbutil/rbutilqt/httpget.cpp @@ -61,15 +61,8 @@ HttpGet::HttpGet(QObject *parent) void HttpGet::setCache(QDir d) { m_cachedir = d; - bool result = true; - - QString p = m_cachedir.absolutePath() + "/rbutil-cache"; - if(QFileInfo(m_cachedir.absolutePath()).isDir()) - { - if(!QFileInfo(p).isDir()) - result = m_cachedir.mkdir("rbutil-cache"); - } - else result = false; + bool result; + result = initializeCache(d); qDebug() << "HttpGet::setCache(QDir)" << d.absolutePath() << result; m_usecache = result; } @@ -79,6 +72,26 @@ void HttpGet::setCache(bool c) { qDebug() << "setCache(bool)" << c; m_usecache = c; + // make sure cache is initialized + if(c) + m_usecache = initializeCache(m_cachedir); +} + + +bool HttpGet::initializeCache(const QDir& d) +{ + bool result; + QString p = d.absolutePath() + "/rbutil-cache"; + if(QFileInfo(d.absolutePath()).isDir()) + { + if(!QFileInfo(p).isDir()) + result = d.mkdir("rbutil-cache"); + } + else + result = false; + + return result; + } diff --git a/rbutil/rbutilqt/httpget.h b/rbutil/rbutilqt/httpget.h index 79522f6e8f..3ff00b4d55 100644 --- a/rbutil/rbutilqt/httpget.h +++ b/rbutil/rbutilqt/httpget.h @@ -66,6 +66,7 @@ class HttpGet : public QObject void httpStarted(int); private: + bool initializeCache(const QDir&); QHttp http; //< download object QFile *outputFile; int response; //< http response |