chain: dont check for null settings value in overwriteRwSetting

- Just call updateRwSetting it will erase the settings when the new
  value is null.
This commit is contained in:
ismaelsadeeq 2024-09-08 20:26:49 +01:00
parent df601993f2
commit f8d91f49c7
No known key found for this signature in database
GPG key ID: 0E3908F364989888
2 changed files with 3 additions and 1 deletions

View file

@ -363,6 +363,9 @@ public:
virtual bool updateRwSetting(const std::string& name, const SettingsUpdate& update_function) = 0;
//! Replace a setting in <datadir>/settings.json with a new value.
//! Null can be passed to erase the setting.
//! This method provides a simpler alternative to updateRwSetting when
//! atomically reading and updating the setting is not required.
virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue value, SettingsAction action = SettingsAction::WRITE) = 0;
//! Delete a given setting in <datadir>/settings.json.

View file

@ -834,7 +834,6 @@ public:
}
bool overwriteRwSetting(const std::string& name, common::SettingsValue value, interfaces::SettingsAction action) override
{
if (value.isNull()) return deleteRwSettings(name, action);
return updateRwSetting(name, [&](common::SettingsValue& settings) {
settings = std::move(value);
return action;