From e075e88c7fb93241bd236271537fdbd88c526d52 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 12 Apr 2022 21:37:26 -0500 Subject: [PATCH] Move mbgl cache to application local data storage --- scwx-qt/source/scwx/qt/main/main_window.cpp | 19 ++++++++++++++++++- scwx-qt/ts/scwx_en_US.ts | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index fd72560c..fd237a56 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,23 @@ public: elevationButtonsChanged_ {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); } ~MainWindowImpl() = default; diff --git a/scwx-qt/ts/scwx_en_US.ts b/scwx-qt/ts/scwx_en_US.ts index 030a9249..35c2eac2 100644 --- a/scwx-qt/ts/scwx_en_US.ts +++ b/scwx-qt/ts/scwx_en_US.ts @@ -102,7 +102,7 @@ scwx::qt::main::MainWindow - + Unrecognized NEXRAD Product: