summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-04-06 17:20:13 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-04-06 17:20:13 +0000
commit2bcc5f782dc9199da7ebfa8f661f673eb6c3de65 (patch)
tree232520a226f8bfc38b8e0366de74c0d242337103 /rbutil
parentf75d409346da1253320864a8af53b26f069dea74 (diff)
downloadrockbox-2bcc5f782dc9199da7ebfa8f661f673eb6c3de65.tar.gz
rockbox-2bcc5f782dc9199da7ebfa8f661f673eb6c3de65.tar.bz2
rockbox-2bcc5f782dc9199da7ebfa8f661f673eb6c3de65.zip
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
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/httpget.cpp31
-rw-r--r--rbutil/rbutilqt/httpget.h1
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