From 87fe124ad7e91df21361f54e45e2c51742b60df9 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 4 Jan 2018 16:39:25 +1300 Subject: update_layer: fix handling of database errors If a database error occurs when we save a recipe (e.g. because a database-level constraint is voilated) it will mess up the transaction. Unfortunately that means we need to break out of updating the entire layer rather than catching the error, because if we do catch it we just get errors on every update after the initial error; failing early and giving up on the transaction is a little better in terms of not filling up the update logs with further useless errors. Signed-off-by: Paul Eggleton --- layerindex/update_layer.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'layerindex/update_layer.py') diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py index 307c43abf2..42e4da93fc 100644 --- a/layerindex/update_layer.py +++ b/layerindex/update_layer.py @@ -56,6 +56,8 @@ def split_recipe_fn(path): return (pn, pv) def update_recipe_file(tinfoil, data, path, recipe, layerdir_start, repodir): + from django.db import DatabaseError + fn = str(os.path.join(path, recipe.filename)) from layerindex.models import PackageConfig, StaticBuildDep, DynamicBuildDep try: @@ -156,6 +158,8 @@ def update_recipe_file(tinfoil, data, path, recipe, layerdir_start, repodir): except KeyboardInterrupt: raise + except DatabaseError: + raise except BaseException as e: if not recipe.pn: recipe.pn = recipe.filename[:-3].split('_')[0] -- cgit 1.2.3-korg