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
This commit is contained in:
parent
f75d409346
commit
2bcc5f782d
2 changed files with 23 additions and 9 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue