From bda50af78098ea0fd549a201bcd0622906ecd23e Mon Sep 17 00:00:00 2001 From: David Kelly Date: Fri, 23 Jun 2017 11:06:48 -0700 Subject: [PATCH] this uses qt's test location for AppData/Local, but leaves Roaming alone --- interface/src/main.cpp | 12 +++++++++--- libraries/shared/src/PathUtils.cpp | 15 +-------------- libraries/shared/src/PathUtils.h | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 0ab00b1e57..81bf0244d9 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -71,7 +71,7 @@ int main(int argc, const char* argv[]) { QCommandLineOption runServerOption("runServer", "Whether to run the server"); QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath"); QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run"); - QCommandLineOption overrideAppLocalDataPathOption("cache", "Override cache directory", "value"); + QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache directory"); parser.addOption(urlOption); parser.addOption(noUpdaterOption); parser.addOption(checkMinSpecOption); @@ -99,8 +99,14 @@ int main(int argc, const char* argv[]) { instanceMightBeRunning = false; } if (parser.isSet(overrideAppLocalDataPathOption)) { - QString appLocalDataPath = parser.value(overrideAppLocalDataPathOption); - PathUtils::getAppLocalDataPath(appLocalDataPath); + // get standard path + auto standardAppDataLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + // set to test so all future paths are the test paths + QStandardPaths::setTestModeEnabled(true); + // now, we need to link everything in AppDataLocation to the test AppDataLocation. This + // leaves the test location for AppLocalDataLocation alone, but allows all the stuff in + // AppDataLocation to be usable + QFile::link(standardAppDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); } if (instanceMightBeRunning) { diff --git a/libraries/shared/src/PathUtils.cpp b/libraries/shared/src/PathUtils.cpp index 63a94c1696..9bf9d7bdcf 100644 --- a/libraries/shared/src/PathUtils.cpp +++ b/libraries/shared/src/PathUtils.cpp @@ -34,20 +34,7 @@ QString PathUtils::getAppDataPath() { return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/"; } -QString PathUtils::getAppLocalDataPath(const QString& overridePath) { - static QString overriddenPath = ""; - - // set the overridden path if one was passed in - if (!overridePath.isEmpty()) { - overriddenPath = overridePath; - } - - // return overridden path if there is one - if (!overriddenPath.isEmpty()) { - return overriddenPath; - } - - // otherwise return the standard path +QString PathUtils::getAppLocalDataPath() { return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/"; } diff --git a/libraries/shared/src/PathUtils.h b/libraries/shared/src/PathUtils.h index 1160fd8106..14eb81dd9a 100644 --- a/libraries/shared/src/PathUtils.h +++ b/libraries/shared/src/PathUtils.h @@ -28,7 +28,7 @@ public: static const QString& resourcesPath(); static QString getAppDataPath(); - static QString getAppLocalDataPath(const QString& overrideDataPath = ""); + static QString getAppLocalDataPath(); static QString getAppDataFilePath(const QString& filename); static QString getAppLocalDataFilePath(const QString& filename);