mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge pull request #10803 from davidkelly/dk/cacheSwitch
new --cache switch for interface
This commit is contained in:
commit
20f713a241
9 changed files with 55 additions and 15 deletions
|
@ -37,8 +37,6 @@
|
||||||
#include <QtQml/QQmlEngine>
|
#include <QtQml/QQmlEngine>
|
||||||
#include <QtQuick/QQuickWindow>
|
#include <QtQuick/QQuickWindow>
|
||||||
|
|
||||||
#include <QtWebEngineWidgets/QWebEngineProfile>
|
|
||||||
|
|
||||||
#include <QtWidgets/QDesktopWidget>
|
#include <QtWidgets/QDesktopWidget>
|
||||||
#include <QtWidgets/QMessageBox>
|
#include <QtWidgets/QMessageBox>
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,7 @@ public:
|
||||||
void setAvatarOverrideUrl(const QUrl& url, bool save);
|
void setAvatarOverrideUrl(const QUrl& url, bool save);
|
||||||
QUrl getAvatarOverrideUrl() { return _avatarOverrideUrl; }
|
QUrl getAvatarOverrideUrl() { return _avatarOverrideUrl; }
|
||||||
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
|
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
|
||||||
|
void setCacheOverrideDir(const QString& dirName) { _cacheDir = dirName; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void svoImportRequested(const QString& url);
|
void svoImportRequested(const QString& url);
|
||||||
|
@ -688,5 +689,7 @@ private:
|
||||||
|
|
||||||
QUrl _avatarOverrideUrl;
|
QUrl _avatarOverrideUrl;
|
||||||
bool _saveAvatarOverrideUrl { false };
|
bool _saveAvatarOverrideUrl { false };
|
||||||
|
|
||||||
|
QString _cacheDir;
|
||||||
};
|
};
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <gl/OpenGLVersionChecker.h>
|
#include <gl/OpenGLVersionChecker.h>
|
||||||
#include <SandboxUtils.h>
|
#include <SandboxUtils.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
#include <NetworkAccessManager.h>
|
||||||
|
|
||||||
#include "AddressManager.h"
|
#include "AddressManager.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -71,15 +72,17 @@ int main(int argc, const char* argv[]) {
|
||||||
QCommandLineOption runServerOption("runServer", "Whether to run the server");
|
QCommandLineOption runServerOption("runServer", "Whether to run the server");
|
||||||
QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath");
|
QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath");
|
||||||
QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run");
|
QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run");
|
||||||
|
QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache <dir>", "dir");
|
||||||
parser.addOption(urlOption);
|
parser.addOption(urlOption);
|
||||||
parser.addOption(noUpdaterOption);
|
parser.addOption(noUpdaterOption);
|
||||||
parser.addOption(checkMinSpecOption);
|
parser.addOption(checkMinSpecOption);
|
||||||
parser.addOption(runServerOption);
|
parser.addOption(runServerOption);
|
||||||
parser.addOption(serverContentPathOption);
|
parser.addOption(serverContentPathOption);
|
||||||
|
parser.addOption(overrideAppLocalDataPathOption);
|
||||||
parser.addOption(allowMultipleInstancesOption);
|
parser.addOption(allowMultipleInstancesOption);
|
||||||
parser.parse(arguments);
|
parser.parse(arguments);
|
||||||
|
|
||||||
|
|
||||||
const QString& applicationName = getInterfaceSharedMemoryName();
|
const QString& applicationName = getInterfaceSharedMemoryName();
|
||||||
bool instanceMightBeRunning = true;
|
bool instanceMightBeRunning = true;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -96,6 +99,19 @@ int main(int argc, const char* argv[]) {
|
||||||
if (allowMultipleInstances) {
|
if (allowMultipleInstances) {
|
||||||
instanceMightBeRunning = false;
|
instanceMightBeRunning = false;
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
ResourceManager::setCacheDir(cacheDir);
|
||||||
|
|
||||||
|
// this does the ktx_cache
|
||||||
|
PathUtils::getAppLocalDataPath(cacheDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (instanceMightBeRunning) {
|
if (instanceMightBeRunning) {
|
||||||
// Try to connect and send message to existing interface instance
|
// Try to connect and send message to existing interface instance
|
||||||
|
@ -179,7 +195,7 @@ int main(int argc, const char* argv[]) {
|
||||||
QString openvrDllPath = appPath + "/plugins/openvr.dll";
|
QString openvrDllPath = appPath + "/plugins/openvr.dll";
|
||||||
HMODULE openvrDll;
|
HMODULE openvrDll;
|
||||||
CHECKMINSPECPROC checkMinSpecPtr;
|
CHECKMINSPECPROC checkMinSpecPtr;
|
||||||
if ((openvrDll = LoadLibrary(openvrDllPath.toLocal8Bit().data())) &&
|
if ((openvrDll = LoadLibrary(openvrDllPath.toLocal8Bit().data())) &&
|
||||||
(checkMinSpecPtr = (CHECKMINSPECPROC)GetProcAddress(openvrDll, "CheckMinSpec"))) {
|
(checkMinSpecPtr = (CHECKMINSPECPROC)GetProcAddress(openvrDll, "CheckMinSpec"))) {
|
||||||
if (!checkMinSpecPtr()) {
|
if (!checkMinSpecPtr()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
MessageID AssetClient::_currentID = 0;
|
MessageID AssetClient::_currentID = 0;
|
||||||
|
|
||||||
AssetClient::AssetClient() {
|
AssetClient::AssetClient(const QString& cacheDir) : _cacheDir(cacheDir) {
|
||||||
setCustomDeleter([](Dependency* dependency){
|
setCustomDeleter([](Dependency* dependency){
|
||||||
static_cast<AssetClient*>(dependency)->deleteLater();
|
static_cast<AssetClient*>(dependency)->deleteLater();
|
||||||
});
|
});
|
||||||
|
@ -55,14 +55,15 @@ void AssetClient::init() {
|
||||||
// Setup disk cache if not already
|
// Setup disk cache if not already
|
||||||
auto& networkAccessManager = NetworkAccessManager::getInstance();
|
auto& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
if (!networkAccessManager.cache()) {
|
if (!networkAccessManager.cache()) {
|
||||||
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
if (_cacheDir.isEmpty()) {
|
||||||
cachePath = !cachePath.isEmpty() ? cachePath : "interfaceCache";
|
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||||
|
_cacheDir = !cachePath.isEmpty() ? cachePath : "interfaceCache";
|
||||||
|
}
|
||||||
QNetworkDiskCache* cache = new QNetworkDiskCache();
|
QNetworkDiskCache* cache = new QNetworkDiskCache();
|
||||||
cache->setMaximumCacheSize(MAXIMUM_CACHE_SIZE);
|
cache->setMaximumCacheSize(MAXIMUM_CACHE_SIZE);
|
||||||
cache->setCacheDirectory(cachePath);
|
cache->setCacheDirectory(_cacheDir);
|
||||||
networkAccessManager.setCache(cache);
|
networkAccessManager.setCache(cache);
|
||||||
qInfo() << "ResourceManager disk cache setup at" << cachePath
|
qInfo() << "ResourceManager disk cache setup at" << _cacheDir
|
||||||
<< "(size:" << MAXIMUM_CACHE_SIZE / BYTES_PER_GIGABYTES << "GB)";
|
<< "(size:" << MAXIMUM_CACHE_SIZE / BYTES_PER_GIGABYTES << "GB)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ using ProgressCallback = std::function<void(qint64 totalReceived, qint64 total)>
|
||||||
class AssetClient : public QObject, public Dependency {
|
class AssetClient : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AssetClient();
|
AssetClient(const QString& cacheDir="");
|
||||||
|
|
||||||
Q_INVOKABLE GetMappingRequest* createGetMappingRequest(const AssetPath& path);
|
Q_INVOKABLE GetMappingRequest* createGetMappingRequest(const AssetPath& path);
|
||||||
Q_INVOKABLE GetAllMappingsRequest* createGetAllMappingsRequest();
|
Q_INVOKABLE GetAllMappingsRequest* createGetAllMappingsRequest();
|
||||||
|
@ -109,6 +109,8 @@ private:
|
||||||
std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, GetInfoCallback>> _pendingInfoRequests;
|
std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, GetInfoCallback>> _pendingInfoRequests;
|
||||||
std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, UploadResultCallback>> _pendingUploads;
|
std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, UploadResultCallback>> _pendingUploads;
|
||||||
|
|
||||||
|
QString _cacheDir;
|
||||||
|
|
||||||
friend class AssetRequest;
|
friend class AssetRequest;
|
||||||
friend class AssetUpload;
|
friend class AssetUpload;
|
||||||
friend class MappingRequest;
|
friend class MappingRequest;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
QThread ResourceManager::_thread;
|
QThread ResourceManager::_thread;
|
||||||
ResourceManager::PrefixMap ResourceManager::_prefixMap;
|
ResourceManager::PrefixMap ResourceManager::_prefixMap;
|
||||||
QMutex ResourceManager::_prefixMapLock;
|
QMutex ResourceManager::_prefixMapLock;
|
||||||
|
QString ResourceManager::_cacheDir;
|
||||||
|
|
||||||
void ResourceManager::setUrlPrefixOverride(const QString& prefix, const QString& replacement) {
|
void ResourceManager::setUrlPrefixOverride(const QString& prefix, const QString& replacement) {
|
||||||
QMutexLocker locker(&_prefixMapLock);
|
QMutexLocker locker(&_prefixMapLock);
|
||||||
|
@ -78,7 +78,7 @@ QUrl ResourceManager::normalizeURL(const QUrl& originalUrl) {
|
||||||
void ResourceManager::init() {
|
void ResourceManager::init() {
|
||||||
_thread.setObjectName("Resource Manager Thread");
|
_thread.setObjectName("Resource Manager Thread");
|
||||||
|
|
||||||
auto assetClient = DependencyManager::set<AssetClient>();
|
auto assetClient = DependencyManager::set<AssetClient>(_cacheDir);
|
||||||
assetClient->moveToThread(&_thread);
|
assetClient->moveToThread(&_thread);
|
||||||
QObject::connect(&_thread, &QThread::started, assetClient.data(), &AssetClient::init);
|
QObject::connect(&_thread, &QThread::started, assetClient.data(), &AssetClient::init);
|
||||||
|
|
||||||
|
@ -164,3 +164,7 @@ bool ResourceManager::resourceExists(const QUrl& url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceManager::setCacheDir(const QString& cacheDir) {
|
||||||
|
// TODO: check for existence?
|
||||||
|
_cacheDir = cacheDir;
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
// to return to the calling thread so that events can still be processed.
|
// to return to the calling thread so that events can still be processed.
|
||||||
static bool resourceExists(const QUrl& url);
|
static bool resourceExists(const QUrl& url);
|
||||||
|
|
||||||
|
// adjust where we persist the cache
|
||||||
|
static void setCacheDir(const QString& cacheDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QThread _thread;
|
static QThread _thread;
|
||||||
|
|
||||||
|
@ -47,6 +50,8 @@ private:
|
||||||
|
|
||||||
static PrefixMap _prefixMap;
|
static PrefixMap _prefixMap;
|
||||||
static QMutex _prefixMapLock;
|
static QMutex _prefixMapLock;
|
||||||
|
|
||||||
|
static QString _cacheDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,7 +34,18 @@ QString PathUtils::getAppDataPath() {
|
||||||
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/";
|
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PathUtils::getAppLocalDataPath() {
|
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 set
|
||||||
|
if (!overriddenPath.isEmpty()) {
|
||||||
|
return overriddenPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise return standard path
|
||||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/";
|
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
static const QString& resourcesPath();
|
static const QString& resourcesPath();
|
||||||
|
|
||||||
static QString getAppDataPath();
|
static QString getAppDataPath();
|
||||||
static QString getAppLocalDataPath();
|
static QString getAppLocalDataPath(const QString& overridePath = "");
|
||||||
|
|
||||||
static QString getAppDataFilePath(const QString& filename);
|
static QString getAppDataFilePath(const QString& filename);
|
||||||
static QString getAppLocalDataFilePath(const QString& filename);
|
static QString getAppLocalDataFilePath(const QString& filename);
|
||||||
|
|
Loading…
Reference in a new issue