mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 02:32:43 +02:00
Don't mark Asset-less DS's backups corrupted
If the DS doesn't choose to run an Asset Server, add an empty mappings file to the archive so they do not show as corrupted
This commit is contained in:
parent
155d6f87c4
commit
caa01aa25e
4 changed files with 22 additions and 15 deletions
|
@ -34,8 +34,9 @@ static const chrono::minutes MAX_REFRESH_TIME { 5 };
|
|||
Q_DECLARE_LOGGING_CATEGORY(asset_backup)
|
||||
Q_LOGGING_CATEGORY(asset_backup, "hifi.asset-backup");
|
||||
|
||||
AssetsBackupHandler::AssetsBackupHandler(const QString& backupDirectory) :
|
||||
_assetsDirectory(backupDirectory + ASSETS_DIR)
|
||||
AssetsBackupHandler::AssetsBackupHandler(const QString& backupDirectory, bool assetServerEnabled) :
|
||||
_assetsDirectory(backupDirectory + ASSETS_DIR),
|
||||
_assetServerEnabled(assetServerEnabled)
|
||||
{
|
||||
// Make sure the asset directory exists.
|
||||
QDir(_assetsDirectory).mkpath(".");
|
||||
|
@ -53,6 +54,7 @@ void AssetsBackupHandler::setupRefreshTimer() {
|
|||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
QObject::connect(nodeList.data(), &LimitedNodeList::nodeActivated, this, [this](SharedNodePointer node) {
|
||||
if (node->getType() == NodeType::AssetServer) {
|
||||
assert(_assetServerEnabled);
|
||||
// run immediately for the first time.
|
||||
_mappingsRefreshTimer.start(0);
|
||||
}
|
||||
|
@ -233,12 +235,12 @@ void AssetsBackupHandler::createBackup(const QString& backupName, QuaZip& zip) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (_lastMappingsRefresh.time_since_epoch().count() == 0) {
|
||||
if (_assetServerEnabled && _lastMappingsRefresh.time_since_epoch().count() == 0) {
|
||||
qCWarning(asset_backup) << "Current mappings not yet loaded.";
|
||||
return;
|
||||
}
|
||||
|
||||
if ((p_high_resolution_clock::now() - _lastMappingsRefresh) > MAX_REFRESH_TIME) {
|
||||
if (_assetServerEnabled && (p_high_resolution_clock::now() - _lastMappingsRefresh) > MAX_REFRESH_TIME) {
|
||||
qCWarning(asset_backup) << "Backing up asset mappings that might be stale.";
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class AssetsBackupHandler : public QObject, public BackupHandlerInterface {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AssetsBackupHandler(const QString& backupDirectory);
|
||||
AssetsBackupHandler(const QString& backupDirectory, bool assetServerEnabled);
|
||||
|
||||
std::pair<bool, float> isAvailable(const QString& backupName) override;
|
||||
std::pair<bool, float> getRecoveryStatus() override;
|
||||
|
@ -65,6 +65,7 @@ private:
|
|||
void updateMappings();
|
||||
|
||||
QString _assetsDirectory;
|
||||
bool _assetServerEnabled { false };
|
||||
|
||||
QTimer _mappingsRefreshTimer;
|
||||
p_high_resolution_clock::time_point _lastMappingsRefresh;
|
||||
|
|
|
@ -308,7 +308,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
|
||||
connect(_contentManager.get(), &DomainContentBackupManager::started, _contentManager.get(), [this](){
|
||||
_contentManager->addBackupHandler(BackupHandlerPointer(new EntitiesBackupHandler(getEntitiesFilePath(), getEntitiesReplacementFilePath())));
|
||||
_contentManager->addBackupHandler(BackupHandlerPointer(new AssetsBackupHandler(getContentBackupDir())));
|
||||
_contentManager->addBackupHandler(BackupHandlerPointer(new AssetsBackupHandler(getContentBackupDir(), isAssetServerEnabled())));
|
||||
_contentManager->addBackupHandler(BackupHandlerPointer(new ContentSettingsBackupHandler(_settingsManager)));
|
||||
});
|
||||
|
||||
|
@ -990,15 +990,11 @@ void DomainServer::populateDefaultStaticAssignmentsExcludingTypes(const QSet<Ass
|
|||
defaultedType = static_cast<Assignment::Type>(static_cast<int>(defaultedType) + 1)) {
|
||||
if (!excludedTypes.contains(defaultedType) && defaultedType != Assignment::AgentType) {
|
||||
|
||||
if (defaultedType == Assignment::AssetServerType) {
|
||||
// Make sure the asset-server is enabled before adding it here.
|
||||
// Initially we do not assign it by default so we can test it in HF domains first
|
||||
static const QString ASSET_SERVER_ENABLED_KEYPATH = "asset_server.enabled";
|
||||
|
||||
if (!_settingsManager.valueOrDefaultValueForKeyPath(ASSET_SERVER_ENABLED_KEYPATH).toBool()) {
|
||||
// skip to the next iteration if asset-server isn't enabled
|
||||
continue;
|
||||
}
|
||||
// Make sure the asset-server is enabled before adding it here.
|
||||
// Initially we do not assign it by default so we can test it in HF domains first
|
||||
if (defaultedType == Assignment::AssetServerType && !isAssetServerEnabled()) {
|
||||
// skip to the next iteraion if asset-server isn't enabled
|
||||
continue;
|
||||
}
|
||||
|
||||
// type has not been set from a command line or config file config, use the default
|
||||
|
@ -2945,6 +2941,12 @@ bool DomainServer::shouldReplicateNode(const Node& node) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
bool DomainServer::isAssetServerEnabled() {
|
||||
static const QString ASSET_SERVER_ENABLED_KEYPATH = "asset_server.enabled";
|
||||
return _settingsManager.valueOrDefaultValueForKeyPath(ASSET_SERVER_ENABLED_KEYPATH).toBool();
|
||||
}
|
||||
|
||||
void DomainServer::nodeAdded(SharedNodePointer node) {
|
||||
// we don't use updateNodeWithData, so add the DomainServerNodeData to the node here
|
||||
node->setLinkedData(std::unique_ptr<DomainServerNodeData> { new DomainServerNodeData() });
|
||||
|
|
|
@ -72,6 +72,8 @@ public:
|
|||
|
||||
static const QString REPLACEMENT_FILE_EXTENSION;
|
||||
|
||||
bool isAssetServerEnabled();
|
||||
|
||||
public slots:
|
||||
/// Called by NodeList to inform us a node has been added
|
||||
void nodeAdded(SharedNodePointer node);
|
||||
|
|
Loading…
Reference in a new issue