diff --git a/src/tree.py b/src/tree.py index 25593b310bf2d8388fd6b05937f3ecfa09d4df75..603a2052e429ee904786e3a789109815a3a8c851 100644 --- a/src/tree.py +++ b/src/tree.py @@ -239,19 +239,25 @@ class TreeWalker: config = load_json(config_path) flag, result = self.ensure_node_id(config) if flag: - dump_json(config_path, config, exist_ok=True, override=True) + dump_json(config_path, result, exist_ok=True, override=True) return config def ensure_node_id(self, config): + flag = False if "node_id" not in config or \ not config["node_id"].startswith(f"{self.tree}-") or \ config["node_id"] in id_set: new_id = self.gen_node_id() id_set.add(new_id) config["node_id"] = new_id - return True, config - else: - return False, config + flag = True + + for child in config.get("children", []): + child_node = list(child.values())[0] + f, _ = self.ensure_node_id(child_node) + flag = flag or f + + return flag, config def gen_node_id(self): return f"{self.name}-{uuid.uuid4().hex}"