Move mbgl cache to application local data storage

This commit is contained in:
Dan Paulat 2022-04-12 21:37:26 -05:00
parent 5489552ff3
commit e075e88c7f
2 changed files with 19 additions and 2 deletions

View file

@ -14,6 +14,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QSplitter> #include <QSplitter>
#include <QStandardPaths>
#include <QToolButton> #include <QToolButton>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
@ -41,7 +42,23 @@ public:
elevationButtonsChanged_ {false}, elevationButtonsChanged_ {false},
resizeElevationButtons_ {false} resizeElevationButtons_ {false}
{ {
settings_.setCacheDatabasePath("/tmp/mbgl-cache.db"); std::string appDataPath {
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
.toStdString()};
std::string cacheDbPath {appDataPath + "/mbgl-cache.db"};
if (!std::filesystem::exists(appDataPath))
{
if (!std::filesystem::create_directories(appDataPath))
{
BOOST_LOG_TRIVIAL(error)
<< logPrefix_
<< "Unable to create application local data directory: \""
<< appDataPath << "\"";
}
}
settings_.setCacheDatabasePath(QString {cacheDbPath.c_str()});
settings_.setCacheDatabaseMaximumSize(20 * 1024 * 1024); settings_.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
} }
~MainWindowImpl() = default; ~MainWindowImpl() = default;

View file

@ -102,7 +102,7 @@
<context> <context>
<name>scwx::qt::main::MainWindow</name> <name>scwx::qt::main::MainWindow</name>
<message> <message>
<location filename="../source/scwx/qt/main/main_window.cpp" line="262"/> <location filename="../source/scwx/qt/main/main_window.cpp" line="279"/>
<source>Unrecognized NEXRAD Product:</source> <source>Unrecognized NEXRAD Product:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>