fix: list every project in template/image in-use refusal, not just the first

The usage scans broke out of the whole (project, node) iteration at the
first matching node, so deleting a template or image used by several
projects reported only one project name while the error message says
'one or more projects'. Keep scanning and list each project once.

Caught on a live server: an IOU L3 template used by two projects
(one of them closed) was refused citing only one of them.
This commit is contained in:
YueGuobin committed 2026-08-31 23:04:00 +08:00
1 parent 13548deae8
commit 823cf37287
2 files changed
+29 -6

No files matched your search

+2 -4
View File
@@ -875,9 +875,8 @@ class Controller:
node_template_id = node.template_id
else:
node_template_id = node.get("template_id")
if node_template_id and str(node_template_id) == template_id:
if node_template_id and str(node_template_id) == template_id and project.name not in project_names:
project_names.append(project.name)
break
return project_names
def find_projects_using_image(self, image_filename: str) -> list:
@@ -894,9 +893,8 @@ class Controller:
node_properties = node.properties
else:
node_properties = node.get("properties") or {}
if _image_referenced(node_properties, image_filename):
if _image_referenced(node_properties, image_filename) and project.name not in project_names:
project_names.append(project.name)
break
return project_names
def collect_referenced_image_filenames(self) -> set: