redo cache switch

This commit is contained in:
David Kelly 2017-07-05 17:01:31 -07:00
parent 64a443ee0d
commit 4a22fbca1b
10 changed files with 38 additions and 49 deletions

View file

@ -480,6 +480,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);
bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt);
// get dir to use for cache
static const auto CACHE_SWITCH = "--cache";
QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH);
if (!cacheDir.isEmpty()) {
qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
}
Setting::init();

View file

@ -111,20 +111,6 @@ int main(int argc, const char* argv[]) {
}
}
if (parser.isSet(overrideAppLocalDataPathOption)) {
// get dir to use for cache
QString cacheDir = parser.value(overrideAppLocalDataPathOption);
if (!cacheDir.isEmpty()) {
// tell everyone to use the right cache location
//
// this handles data8 and prepared
DependencyManager::get<ResourceManager>()->setCacheDir(cacheDir);
// this does the ktx_cache
PathUtils::getAppLocalDataPath(cacheDir);
}
}
if (instanceMightBeRunning) {
// Try to connect and send message to existing interface instance
QLocalSocket socket;

View file

@ -19,6 +19,8 @@
#include <QtScript/QScriptEngine>
#include <QtNetwork/QNetworkDiskCache>
#include <shared/GlobalAppProperties.h>
#include "AssetRequest.h"
#include "AssetUpload.h"
#include "AssetUtils.h"
@ -31,7 +33,8 @@
MessageID AssetClient::_currentID = 0;
AssetClient::AssetClient(const QString& cacheDir) : _cacheDir(cacheDir) {
AssetClient::AssetClient() {
_cacheDir = qApp->property(hifi::properties::APP_LOCAL_DATA_PATH).toString();
setCustomDeleter([](Dependency* dependency){
static_cast<AssetClient*>(dependency)->deleteLater();
});

View file

@ -49,7 +49,7 @@ using ProgressCallback = std::function<void(qint64 totalReceived, qint64 total)>
class AssetClient : public QObject, public Dependency {
Q_OBJECT
public:
AssetClient(const QString& cacheDir="");
AssetClient();
Q_INVOKABLE GetMappingRequest* createGetMappingRequest(const AssetPath& path);
Q_INVOKABLE GetAllMappingsRequest* createGetAllMappingsRequest();

View file

@ -28,7 +28,7 @@
ResourceManager::ResourceManager() {
_thread.setObjectName("Resource Manager Thread");
auto assetClient = DependencyManager::set<AssetClient>(_cacheDir);
auto assetClient = DependencyManager::set<AssetClient>();
assetClient->moveToThread(&_thread);
QObject::connect(&_thread, &QThread::started, assetClient.data(), &AssetClient::init);
@ -160,7 +160,3 @@ bool ResourceManager::resourceExists(const QUrl& url) {
return false;
}
void ResourceManager::setCacheDir(const QString& cacheDir) {
// TODO: check for existence?
_cacheDir = cacheDir;
}

View file

@ -59,7 +59,6 @@ private:
PrefixMap _prefixMap;
QMutex _prefixMapLock;
QString _cacheDir;
};
#endif

View file

@ -19,6 +19,7 @@
#include "PathUtils.h"
#include <QtCore/QStandardPaths>
#include <mutex> // std::once
#include "shared/GlobalAppProperties.h"
const QString& PathUtils::resourcesPath() {
#ifdef Q_OS_MAC
@ -34,12 +35,8 @@ 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;
}
QString PathUtils::getAppLocalDataPath() {
QString overriddenPath = qApp->property(hifi::properties::APP_LOCAL_DATA_PATH).toString();
// return overridden path if set
if (!overriddenPath.isEmpty()) {
return overriddenPath;

View file

@ -28,7 +28,7 @@ public:
static const QString& resourcesPath();
static QString getAppDataPath();
static QString getAppLocalDataPath(const QString& overridePath = "");
static QString getAppLocalDataPath();
static QString getAppDataFilePath(const QString& filename);
static QString getAppLocalDataFilePath(const QString& filename);

View file

@ -17,6 +17,7 @@ namespace hifi { namespace properties {
const char* TEST = "com.highfidelity.test";
const char* TRACING = "com.highfidelity.tracing";
const char* HMD = "com.highfidelity.hmd";
const char* APP_LOCAL_DATA_PATH = "com.highfidelity.appLocalDataPath";
namespace gl {
const char* BACKEND = "com.highfidelity.gl.backend";

View file

@ -19,6 +19,7 @@ namespace hifi { namespace properties {
extern const char* TEST;
extern const char* TRACING;
extern const char* HMD;
extern const char* APP_LOCAL_DATA_PATH;
namespace gl {
extern const char* BACKEND;