Skip to contentSkip to conversation

update.py: fix updates_enabled for newbranch

PATCH New Tim Orling 1 participant 1 message Nov 9, 2023

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

PATCH 1/1 update.py: fix updates_enabled for newbranch

When a new release is run for the first time, no LayerBranch exists yet and the update_enabled cannot be queried. The unintended result is that all layers are skipped. Move the update_enabled check into the code path where the layerbranch already exists.

---
 layerindex/update.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
layerindex/update.py +6 -5
index e7e5c63..3da74e3 100755
@@ -361,6 +361,12 @@ def main():
                         if layerbranch.actual_branch:
                             branchname = layerbranch.actual_branch
                             branchdesc = "%s (%s)" % (branch, branchname)
+
+                        layerbranch_updates_enabled = LayerBranch.objects.filter(layer=layer,
+			                                                         branch=branchobj.id, updates_enabled=True)
+                        if not layerbranch_updates_enabled:
+                            logger.info("Skipping update of layer %s branch %s - updates disabled" % (layer.name, branchname))
+                            continue
                     else:
                         # LayerBranch doesn't exist for this branch, create it temporarily
                         # (we won't save this - update_layer.py will do the actual creation
@@ -375,11 +381,6 @@ def main():
                         if layerbranch_source:
                             layerbranch.vcs_subdir = layerbranch_source.vcs_subdir
 
-                    layerbranch_updates_enabled = LayerBranch.objects.filter(layer=layer, branch=branchobj.id, updates_enabled=True)
-                    if not layerbranch_updates_enabled:
-                        logger.info("Skipping update of layer %s  branch %s - updates disabled" % (layer.name, branchname))
-                        continue
-
                     # Collect repo info
                     urldir = layer.get_fetch_dir()
                     repodir = os.path.join(fetchdir, urldir)
Signature · 1 line
2.34.1