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 /rbutil/rbutilqt/httpget.cpp | |
parent | f75d409346da1253320864a8af53b26f069dea74 (diff) | |
download | rockbox-2bcc5f782dc9199da7ebfa8f661f673eb6c3de65.tar.gz 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/rbutilqt/httpget.cpp')
-rw-r--r-- | rbutil/rbutilqt/httpget.cpp | 31 |
1 files changed, 22 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) | |||
61 | void HttpGet::setCache(QDir d) | 61 | void HttpGet::setCache(QDir d) |
62 | { | 62 | { |
63 | m_cachedir = d; | 63 | m_cachedir = d; |
64 | bool result = true; | 64 | bool result; |
65 | 65 | result = initializeCache(d); | |
66 | QString p = m_cachedir.absolutePath() + "/rbutil-cache"; | ||
67 | if(QFileInfo(m_cachedir.absolutePath()).isDir()) | ||
68 | { | ||
69 | if(!QFileInfo(p).isDir()) | ||
70 | result = m_cachedir.mkdir("rbutil-cache"); | ||
71 | } | ||
72 | else result = false; | ||
73 | qDebug() << "HttpGet::setCache(QDir)" << d.absolutePath() << result; | 66 | qDebug() << "HttpGet::setCache(QDir)" << d.absolutePath() << result; |
74 | m_usecache = result; | 67 | m_usecache = result; |
75 | } | 68 | } |
@@ -79,6 +72,26 @@ void HttpGet::setCache(bool c) | |||
79 | { | 72 | { |
80 | qDebug() << "setCache(bool)" << c; | 73 | qDebug() << "setCache(bool)" << c; |
81 | m_usecache = c; | 74 | m_usecache = c; |
75 | // make sure cache is initialized | ||
76 | if(c) | ||
77 | m_usecache = initializeCache(m_cachedir); | ||
78 | } | ||
79 | |||
80 | |||
81 | bool HttpGet::initializeCache(const QDir& d) | ||
82 | { | ||
83 | bool result; | ||
84 | QString p = d.absolutePath() + "/rbutil-cache"; | ||
85 | if(QFileInfo(d.absolutePath()).isDir()) | ||
86 | { | ||
87 | if(!QFileInfo(p).isDir()) | ||
88 | result = d.mkdir("rbutil-cache"); | ||
89 | } | ||
90 | else | ||
91 | result = false; | ||
92 | |||
93 | return result; | ||
94 | |||
82 | } | 95 | } |
83 | 96 | ||
84 | 97 | ||