remove master config from HifiConfigVariantMap/domain-server

This commit is contained in:
Stephen Birarda 2017-10-31 14:34:17 -07:00 committed by Atlante45
parent c0f44c8fc8
commit b8370128ce
3 changed files with 2 additions and 62 deletions

View file

@ -100,8 +100,7 @@ void DomainServerSettingsManager::processSettingsRequestPacket(QSharedPointer<Re
void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList) { void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList) {
_argumentList = argumentList; _argumentList = argumentList;
// after 1.7 we no longer use the master or merged configs - this is kept in place for migration _configMap.loadConfig(_argumentList);
_configMap.loadMasterAndUserConfig(_argumentList);
// What settings version were we before and what are we using now? // What settings version were we before and what are we using now?
// Do we need to do any re-mapping? // Do we need to do any re-mapping?
@ -140,9 +139,6 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
// write the new settings to the json file // write the new settings to the json file
persistToFile(); persistToFile();
// reload the master and user config so that the merged config is right
_configMap.loadMasterAndUserConfig(_argumentList);
} }
} }
@ -175,9 +171,6 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
// write the new settings to the json file // write the new settings to the json file
persistToFile(); persistToFile();
// reload the master and user config so that the merged config is right
_configMap.loadMasterAndUserConfig(_argumentList);
} }
} }
@ -198,9 +191,6 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
// write the new settings to file // write the new settings to file
persistToFile(); persistToFile();
// reload the master and user config so the merged config is correct
_configMap.loadMasterAndUserConfig(_argumentList);
} }
} }
@ -283,19 +273,6 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
packPermissions(); packPermissions();
} }
if (oldVersion < 1.7) {
// This was prior to the removal of the master config file
// So we write the merged config to the user config file, and stop reading from the user config file
qDebug() << "Migrating merged config to user config file. The master config file is deprecated.";
// replace the user config by the merged config
_configMap.getConfig() = _configMap.getMergedConfig();
// persist the new config so the user config file has the correctly merged config
persistToFile();
}
if (oldVersion < 1.8) { if (oldVersion < 1.8) {
unpackPermissions(); unpackPermissions();
// This was prior to addition of domain content replacement, add that to localhost permissions by default // This was prior to addition of domain content replacement, add that to localhost permissions by default
@ -1289,9 +1266,6 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
} }
} }
// re-merge the user and master configs after a settings change
_configMap.mergeMasterAndUserConfigs();
return needRestart; return needRestart;
} }

View file

@ -92,31 +92,11 @@ QVariantMap HifiConfigVariantMap::mergeCLParametersWithJSONConfig(const QStringL
} }
HifiConfigVariantMap::HifiConfigVariantMap() : HifiConfigVariantMap::HifiConfigVariantMap() :
_userConfigFilename(), _userConfigFilename()
_masterConfig(),
_userConfig(),
_mergedConfig()
{ {
} }
void HifiConfigVariantMap::loadMasterAndUserConfig(const QStringList& argumentList) {
// check if there is a master config file
const QString MASTER_CONFIG_FILE_OPTION = "--master-config";
int masterConfigIndex = argumentList.indexOf(MASTER_CONFIG_FILE_OPTION);
if (masterConfigIndex != -1) {
QString masterConfigFilepath = argumentList[masterConfigIndex + 1];
loadMapFromJSONFile(_masterConfig, masterConfigFilepath);
}
// load the user config - that method replace loadMasterAndUserConfig after the 1.7 migration
loadConfig(argumentList);
mergeMasterAndUserConfigs();
}
void HifiConfigVariantMap::loadConfig(const QStringList& argumentList) { void HifiConfigVariantMap::loadConfig(const QStringList& argumentList) {
// load the user config // load the user config
const QString USER_CONFIG_FILE_OPTION = "--user-config"; const QString USER_CONFIG_FILE_OPTION = "--user-config";
@ -172,14 +152,6 @@ void HifiConfigVariantMap::loadConfig(const QStringList& argumentList) {
loadMapFromJSONFile(_userConfig, _userConfigFilename); loadMapFromJSONFile(_userConfig, _userConfigFilename);
} }
void HifiConfigVariantMap::mergeMasterAndUserConfigs() {
// the merged config is initially matched to the master config
_mergedConfig = _masterConfig;
// then we merge in anything missing from the user config
addMissingValuesToExistingMap(_mergedConfig, _userConfig);
}
void HifiConfigVariantMap::loadMapFromJSONFile(QVariantMap& existingMap, const QString& filename) { void HifiConfigVariantMap::loadMapFromJSONFile(QVariantMap& existingMap, const QString& filename) {
QFile configFile(filename); QFile configFile(filename);

View file

@ -22,25 +22,19 @@ public:
static QVariantMap mergeCLParametersWithJSONConfig(const QStringList& argumentList); static QVariantMap mergeCLParametersWithJSONConfig(const QStringList& argumentList);
HifiConfigVariantMap(); HifiConfigVariantMap();
void loadMasterAndUserConfig(const QStringList& argumentList);
void loadConfig(const QStringList& argumentList); void loadConfig(const QStringList& argumentList);
const QVariant value(const QString& key) const { return _userConfig.value(key); } const QVariant value(const QString& key) const { return _userConfig.value(key); }
QVariant* valueForKeyPath(const QString& keyPath, bool shouldCreateIfMissing = false) QVariant* valueForKeyPath(const QString& keyPath, bool shouldCreateIfMissing = false)
{ return ::valueForKeyPath(_userConfig, keyPath, shouldCreateIfMissing); } { return ::valueForKeyPath(_userConfig, keyPath, shouldCreateIfMissing); }
QVariantMap& getMergedConfig() { return _mergedConfig; }
QVariantMap& getConfig() { return _userConfig; } QVariantMap& getConfig() { return _userConfig; }
void mergeMasterAndUserConfigs();
const QString& getUserConfigFilename() const { return _userConfigFilename; } const QString& getUserConfigFilename() const { return _userConfigFilename; }
private: private:
QString _userConfigFilename; QString _userConfigFilename;
QVariantMap _masterConfig;
QVariantMap _userConfig; QVariantMap _userConfig;
QVariantMap _mergedConfig;
void loadMapFromJSONFile(QVariantMap& existingMap, const QString& filename); void loadMapFromJSONFile(QVariantMap& existingMap, const QString& filename);
void addMissingValuesToExistingMap(QVariantMap& existingMap, const QVariantMap& newMap); void addMissingValuesToExistingMap(QVariantMap& existingMap, const QVariantMap& newMap);