fix: user_data better support for follower variable

This commit is contained in:
egarette@silique.fr 2025-05-19 19:08:32 +02:00
parent b902e15243
commit 9e06f1142e

View file

@ -218,6 +218,9 @@ class UserDatas:
if not isinstance(value, list) or index >= len(value):
continue
value = value[index]
option_without_index = self.config.option(path)
else:
option_without_index = option
if option.isleader():
len_leader = len(option.value.get())
if len_leader:
@ -225,21 +228,26 @@ class UserDatas:
option.value.pop(idx)
try:
option.value.set(value)
option.information.set(
"loaded_from", _("loaded from {0}").format(self.values[path]["source"])
)
value_is_set = True
except Exception:
if path != option.path():
self.values[option.path()] = self.values.pop(path)
else:
if "source" in self.values[path]:
option_without_index.information.set(
"loaded_from", _("loaded from {0}").format(self.values[path]["source"])
)
# value is correctly set, remove variable to the set
if index is not None:
# if it's a follower waiting for all followers are sets
self.values[path]["values"][index] = undefined
if set(self.values[path]["values"]) == {undefined}:
for tmp_value in self.values[path]["values"]:
if tmp_value != undefined:
break
else:
self.values.pop(path)
else:
self.values.pop(path)
except Exception:
if path != option.path():
self.values[option.path()] = self.values.pop(path)
if not value_is_set:
break