Fix: Persist all data different from default, not just current changes
We need to merge with our current data since we only might get partial data from our caller.
This commit is contained in:
parent
d70fe32750
commit
7ea1578bda
2 changed files with 20 additions and 3 deletions
|
|
@ -448,6 +448,18 @@ class PluginSettings(object):
|
|||
return path
|
||||
|
||||
def get_all_data(self, **kwargs):
|
||||
merged = kwargs.get("merged", True)
|
||||
asdict = kwargs.get("asdict", True)
|
||||
defaults = kwargs.get("defaults", self.defaults)
|
||||
preprocessors = kwargs.get("preprocessors", self.get_preprocessors)
|
||||
|
||||
kwargs.update(dict(
|
||||
merged=merged,
|
||||
asdict=asdict,
|
||||
defaults=defaults,
|
||||
preprocessors=preprocessors
|
||||
))
|
||||
|
||||
return self.settings.get(self._prefix_path(), **kwargs)
|
||||
|
||||
def clean_all_data(self):
|
||||
|
|
|
|||
|
|
@ -1238,12 +1238,17 @@ class SettingsPlugin(OctoPrintPlugin):
|
|||
"""
|
||||
import octoprint.util
|
||||
|
||||
if self.config_version_key in data:
|
||||
del data[self.config_version_key]
|
||||
# get the current data
|
||||
current = self._settings.get_all_data()
|
||||
|
||||
# merge our new data on top of it
|
||||
new_current = octoprint.util.dict_merge(current, data)
|
||||
if self.config_version_key in new_current:
|
||||
del new_current[self.config_version_key]
|
||||
|
||||
# determine diff dict that contains minimal set of changes against the
|
||||
# default settings - we only want to persist that, not everything
|
||||
diff = octoprint.util.dict_diff(self.get_settings_defaults(), data)
|
||||
diff = octoprint.util.dict_diff(self.get_settings_defaults(), new_current)
|
||||
|
||||
version = self.get_settings_version()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue