Skip to content

Commit

Permalink
Merge pull request #30077 from m-kuhn/cache_location
Browse files Browse the repository at this point in the history
Use system cache location instead of profile folder for network cache
  • Loading branch information
m-kuhn committed Jun 5, 2019
2 parents 74d6b23 + 4cd0121 commit 4bca6a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/app/qgsoptions.cpp
Expand Up @@ -374,12 +374,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti

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

Expand Down
5 changes: 3 additions & 2 deletions src/core/qgsnetworkaccessmanager.cpp
Expand Up @@ -37,6 +37,7 @@
#include <QNetworkReply>
#include <QThreadStorage>
#include <QAuthenticator>
#include <QStandardPaths>

#ifndef QT_NO_SSL
#include <QSslConfiguration>
Expand Down Expand Up @@ -601,8 +602,8 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType conn

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

0 comments on commit 4bca6a8

Please sign in to comment.