mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Merge pull request #15278 from kitely/clear-more-disk-caches
case 21983: Clear more disk caches
This commit is contained in:
commit
048626ba9a
6 changed files with 68 additions and 3 deletions
|
@ -29,6 +29,8 @@
|
||||||
#include <VrMenu.h>
|
#include <VrMenu.h>
|
||||||
#include <ScriptEngines.h>
|
#include <ScriptEngines.h>
|
||||||
#include <MenuItemProperties.h>
|
#include <MenuItemProperties.h>
|
||||||
|
#include <ui/types/FileTypeProfile.h>
|
||||||
|
#include <ui/types/HFWebEngineProfile.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "AccountManager.h"
|
#include "AccountManager.h"
|
||||||
|
@ -582,8 +584,20 @@ Menu::Menu() {
|
||||||
QString("hifi/tablet/TabletNetworkingPreferences.qml"), "NetworkingPreferencesDialog");
|
QString("hifi/tablet/TabletNetworkingPreferences.qml"), "NetworkingPreferencesDialog");
|
||||||
});
|
});
|
||||||
addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));
|
addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));
|
||||||
addActionToQMenuAndActionHash(networkMenu, MenuOption::ClearDiskCache, 0,
|
|
||||||
DependencyManager::get<AssetClient>().data(), SLOT(clearCache()));
|
action = addActionToQMenuAndActionHash(networkMenu, MenuOption::ClearDiskCaches);
|
||||||
|
connect(action, &QAction::triggered, [] {
|
||||||
|
// The following caches are cleared immediately
|
||||||
|
DependencyManager::get<AssetClient>()->clearCache();
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
|
FileTypeProfile::clearCache();
|
||||||
|
HFWebEngineProfile::clearCache();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Clear the KTX cache on the next restart. It can't be cleared immediately because its files might be in use.
|
||||||
|
Setting::Handle<int>(KTXCache::SETTING_VERSION_NAME, KTXCache::INVALID_VERSION).set(KTXCache::INVALID_VERSION);
|
||||||
|
});
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(networkMenu,
|
addCheckableActionToQMenuAndActionHash(networkMenu,
|
||||||
MenuOption::DisableActivityLogger,
|
MenuOption::DisableActivityLogger,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace MenuOption {
|
||||||
const QString CalibrateCamera = "Calibrate Camera";
|
const QString CalibrateCamera = "Calibrate Camera";
|
||||||
const QString CenterPlayerInView = "Center Player In View";
|
const QString CenterPlayerInView = "Center Player In View";
|
||||||
const QString Chat = "Chat...";
|
const QString Chat = "Chat...";
|
||||||
const QString ClearDiskCache = "Clear Disk Cache";
|
const QString ClearDiskCaches = "Clear Disk Caches (requires restart)";
|
||||||
const QString Collisions = "Collisions";
|
const QString Collisions = "Collisions";
|
||||||
const QString Connexion = "Activate 3D Connexion Devices";
|
const QString Connexion = "Activate 3D Connexion Devices";
|
||||||
const QString Console = "Console...";
|
const QString Console = "Console...";
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "FileTypeProfile.h"
|
#include "FileTypeProfile.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <mutex>
|
||||||
#include <QtQml/QQmlContext>
|
#include <QtQml/QQmlContext>
|
||||||
|
|
||||||
#include "RequestFilters.h"
|
#include "RequestFilters.h"
|
||||||
|
@ -18,14 +20,28 @@
|
||||||
#if !defined(Q_OS_ANDROID)
|
#if !defined(Q_OS_ANDROID)
|
||||||
static const QString QML_WEB_ENGINE_STORAGE_NAME = "qmlWebEngine";
|
static const QString QML_WEB_ENGINE_STORAGE_NAME = "qmlWebEngine";
|
||||||
|
|
||||||
|
static std::set<FileTypeProfile*> FileTypeProfile_instances;
|
||||||
|
static std::mutex FileTypeProfile_mutex;
|
||||||
|
|
||||||
FileTypeProfile::FileTypeProfile(QQmlContext* parent) :
|
FileTypeProfile::FileTypeProfile(QQmlContext* parent) :
|
||||||
ContextAwareProfile(parent)
|
ContextAwareProfile(parent)
|
||||||
{
|
{
|
||||||
static const QString WEB_ENGINE_USER_AGENT = "Chrome/48.0 (HighFidelityInterface)";
|
static const QString WEB_ENGINE_USER_AGENT = "Chrome/48.0 (HighFidelityInterface)";
|
||||||
setHttpUserAgent(WEB_ENGINE_USER_AGENT);
|
setHttpUserAgent(WEB_ENGINE_USER_AGENT);
|
||||||
|
|
||||||
|
setStorageName(QML_WEB_ENGINE_STORAGE_NAME);
|
||||||
|
setOffTheRecord(false);
|
||||||
|
|
||||||
auto requestInterceptor = new RequestInterceptor(this);
|
auto requestInterceptor = new RequestInterceptor(this);
|
||||||
setRequestInterceptor(requestInterceptor);
|
setRequestInterceptor(requestInterceptor);
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(FileTypeProfile_mutex);
|
||||||
|
FileTypeProfile_instances.insert(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileTypeProfile::~FileTypeProfile() {
|
||||||
|
std::lock_guard<std::mutex> lock(FileTypeProfile_mutex);
|
||||||
|
FileTypeProfile_instances.erase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTypeProfile::RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
void FileTypeProfile::RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
||||||
|
@ -37,5 +53,11 @@ void FileTypeProfile::registerWithContext(QQmlContext* context) {
|
||||||
context->setContextProperty("FileTypeProfile", new FileTypeProfile(context));
|
context->setContextProperty("FileTypeProfile", new FileTypeProfile(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileTypeProfile::clearCache() {
|
||||||
|
std::lock_guard<std::mutex> lock(FileTypeProfile_mutex);
|
||||||
|
foreach (auto instance, FileTypeProfile_instances) {
|
||||||
|
instance->clearHttpCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -25,8 +25,12 @@ class FileTypeProfile : public ContextAwareProfile {
|
||||||
public:
|
public:
|
||||||
static void registerWithContext(QQmlContext* parent);
|
static void registerWithContext(QQmlContext* parent);
|
||||||
|
|
||||||
|
static void clearCache();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileTypeProfile(QQmlContext* parent);
|
FileTypeProfile(QQmlContext* parent);
|
||||||
|
virtual ~FileTypeProfile();
|
||||||
|
|
||||||
class RequestInterceptor : public Parent::RequestInterceptor {
|
class RequestInterceptor : public Parent::RequestInterceptor {
|
||||||
public:
|
public:
|
||||||
RequestInterceptor(ContextAwareProfile* parent) : Parent::RequestInterceptor(parent) {}
|
RequestInterceptor(ContextAwareProfile* parent) : Parent::RequestInterceptor(parent) {}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "HFWebEngineProfile.h"
|
#include "HFWebEngineProfile.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <mutex>
|
||||||
#include <QtQml/QQmlContext>
|
#include <QtQml/QQmlContext>
|
||||||
|
|
||||||
#include "RequestFilters.h"
|
#include "RequestFilters.h"
|
||||||
|
@ -19,12 +21,24 @@
|
||||||
|
|
||||||
static const QString QML_WEB_ENGINE_STORAGE_NAME = "qmlWebEngine";
|
static const QString QML_WEB_ENGINE_STORAGE_NAME = "qmlWebEngine";
|
||||||
|
|
||||||
|
static std::set<HFWebEngineProfile*> HFWebEngineProfile_instances;
|
||||||
|
static std::mutex HFWebEngineProfile_mutex;
|
||||||
|
|
||||||
HFWebEngineProfile::HFWebEngineProfile(QQmlContext* parent) : Parent(parent)
|
HFWebEngineProfile::HFWebEngineProfile(QQmlContext* parent) : Parent(parent)
|
||||||
{
|
{
|
||||||
setStorageName(QML_WEB_ENGINE_STORAGE_NAME);
|
setStorageName(QML_WEB_ENGINE_STORAGE_NAME);
|
||||||
|
setOffTheRecord(false);
|
||||||
|
|
||||||
// we use the HFWebEngineRequestInterceptor to make sure that web requests are authenticated for the interface user
|
// we use the HFWebEngineRequestInterceptor to make sure that web requests are authenticated for the interface user
|
||||||
setRequestInterceptor(new RequestInterceptor(this));
|
setRequestInterceptor(new RequestInterceptor(this));
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(HFWebEngineProfile_mutex);
|
||||||
|
HFWebEngineProfile_instances.insert(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
HFWebEngineProfile::~HFWebEngineProfile() {
|
||||||
|
std::lock_guard<std::mutex> lock(HFWebEngineProfile_mutex);
|
||||||
|
HFWebEngineProfile_instances.erase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HFWebEngineProfile::RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
void HFWebEngineProfile::RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
||||||
|
@ -35,4 +49,11 @@ void HFWebEngineProfile::registerWithContext(QQmlContext* context) {
|
||||||
context->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(context));
|
context->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HFWebEngineProfile::clearCache() {
|
||||||
|
std::lock_guard<std::mutex> lock(HFWebEngineProfile_mutex);
|
||||||
|
foreach (auto instance, HFWebEngineProfile_instances) {
|
||||||
|
instance->clearHttpCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,8 +23,12 @@ class HFWebEngineProfile : public ContextAwareProfile {
|
||||||
public:
|
public:
|
||||||
static void registerWithContext(QQmlContext* parent);
|
static void registerWithContext(QQmlContext* parent);
|
||||||
|
|
||||||
|
static void clearCache();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HFWebEngineProfile(QQmlContext* parent);
|
HFWebEngineProfile(QQmlContext* parent);
|
||||||
|
virtual ~HFWebEngineProfile();
|
||||||
|
|
||||||
class RequestInterceptor : public Parent::RequestInterceptor {
|
class RequestInterceptor : public Parent::RequestInterceptor {
|
||||||
public:
|
public:
|
||||||
RequestInterceptor(ContextAwareProfile* parent) : Parent::RequestInterceptor(parent) {}
|
RequestInterceptor(ContextAwareProfile* parent) : Parent::RequestInterceptor(parent) {}
|
||||||
|
|
Loading…
Reference in a new issue