From bca6af49ffe39d6c01b3925c7b93b39cecaa2d25 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 2 Apr 2021 12:57:30 +0200 Subject: T3165: prevent override of populated node.def file with empty content (cherry picked from commit b4fdcebebecd8d8952211b78bce26d53fd29edb3) --- scripts/build-command-op-templates | 7 +++---- scripts/build-command-templates | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates index c60b32a1e..c285ee594 100755 --- a/scripts/build-command-op-templates +++ b/scripts/build-command-op-templates @@ -170,12 +170,11 @@ def process_node(n, tmpl_dir): print("Processing node {}".format(name)) nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def") - if not os.path.exists(nodedef_path): + # Only create the "node.def" file if it exists but is empty, or if it + # does not exist at all. + if not os.path.exists(nodedef_path) or os.path.getsize(nodedef_path) == 0: with open(nodedef_path, "w") as f: f.write(make_node_def(props, command)) - else: - # Something has already generated this file - pass if children is not None: inner_nodes = children.iterfind("*") diff --git a/scripts/build-command-templates b/scripts/build-command-templates index d6585b0cc..452c420eb 100755 --- a/scripts/build-command-templates +++ b/scripts/build-command-templates @@ -274,13 +274,14 @@ def process_node(n, tmpl_dir): raise ValueError(" is only allowed in ") nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def") - if not os.path.exists(nodedef_path): + + # Only create the "node.def" file if it exists but is empty, or if it does + # not exist at all. An empty node.def file could be generated by XML paths + # that derive from one another bot having a common base structure like + # "protocols static" + if not os.path.exists(nodedef_path) or os.path.getsize(nodedef_path) == 0: with open(nodedef_path, "w") as f: f.write(make_node_def(props)) - else: - # Something has already generated that file - pass - if node_type == "node": inner_nodes = children.iterfind("*") -- cgit v1.2.3