Skip to content

Commit 1b6e412

Browse files
committed
refine evaluate_product_rules_on_package_save
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent cb94f97 commit 1b6e412

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

policy/signals.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def evaluate_product_rules_on_productpackage_delete(sender, instance, **kwargs):
3737

3838

3939
@receiver(post_save, sender="component_catalog.Package")
40-
def evaluate_product_rules_on_package_save(sender, instance, **kwargs):
40+
def evaluate_product_rules_on_package_save(sender, instance, created, **kwargs):
4141
"""Queue a policy rule evaluation for all products containing this package."""
42+
if created:
43+
return # A newly created package has no ProductPackage relations yet.
44+
4245
product_uuids = list(instance.productpackages.values_list("product__uuid", flat=True))
4346
if product_uuids:
4447
evaluate_all_products_rules_task.delay(product_uuids=product_uuids)

0 commit comments

Comments
 (0)