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.

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
This commit is contained in:
Tim Orling 2023-11-09 12:11:54 -08:00
parent 3dc125d9c1
commit b3bfbd1479

View File

@ -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)