Skip to content

Commit 4bca6a8

Browse files
authoredJun 5, 2019
Merge pull request #30077 from m-kuhn/cache_location
Use system cache location instead of profile folder for network cache
2 parents 74d6b23 + 4cd0121 commit 4bca6a8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
374374

375375
// cache settings
376376
mCacheDirectory->setText( mSettings->value( QStringLiteral( "cache/directory" ) ).toString() );
377-
mCacheDirectory->setPlaceholderText( QDir( QgsApplication::qgisSettingsDirPath() ).canonicalPath() + QDir::separator() + QStringLiteral( "cache" ) );
377+
mCacheDirectory->setPlaceholderText( QStandardPaths::writableLocation( QStandardPaths::CacheLocation ) );
378378
mCacheSize->setMinimum( 0 );
379379
mCacheSize->setMaximum( std::numeric_limits<int>::max() );
380380
mCacheSize->setSingleStep( 1024 );
381-
qint64 cacheSize = mSettings->value( QStringLiteral( "cache/size" ), 50 * 1024 * 1024 ).toULongLong();
382-
mCacheSize->setValue( ( int )( cacheSize / 1024 ) );
381+
qint64 cacheSize = mSettings->value( QStringLiteral( "cache/size" ), 50 * 1024 * 1024 ).toLongLong();
382+
mCacheSize->setValue( static_cast<int>( cacheSize / 1024 ) );
383383
connect( mBrowseCacheDirectory, &QAbstractButton::clicked, this, &QgsOptions::browseCacheDirectory );
384384
connect( mClearCache, &QAbstractButton::clicked, this, &QgsOptions::clearCache );
385385

‎src/core/qgsnetworkaccessmanager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <QNetworkReply>
3838
#include <QThreadStorage>
3939
#include <QAuthenticator>
40+
#include <QStandardPaths>
4041

4142
#ifndef QT_NO_SSL
4243
#include <QSslConfiguration>
@@ -601,8 +602,8 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType conn
601602

602603
QString cacheDirectory = settings.value( QStringLiteral( "cache/directory" ) ).toString();
603604
if ( cacheDirectory.isEmpty() )
604-
cacheDirectory = QgsApplication::qgisSettingsDirPath() + "cache";
605-
qint64 cacheSize = settings.value( QStringLiteral( "cache/size" ), 50 * 1024 * 1024 ).toULongLong();
605+
cacheDirectory = QStandardPaths::writableLocation( QStandardPaths::CacheLocation );
606+
qint64 cacheSize = settings.value( QStringLiteral( "cache/size" ), 50 * 1024 * 1024 ).toLongLong();
606607
newcache->setCacheDirectory( cacheDirectory );
607608
newcache->setMaximumCacheSize( cacheSize );
608609
QgsDebugMsgLevel( QStringLiteral( "cacheDirectory: %1" ).arg( newcache->cacheDirectory() ), 4 );

0 commit comments

Comments
 (0)
Please sign in to comment.