Skip to content

Commit 7a73aa1

Browse files
committed
yield child record before try except continue
1 parent 1734307 commit 7a73aa1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

dissect/target/target.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,18 +493,21 @@ def list_children_recursive(self, prefix: str = "") -> Iterator[tuple[str, tuple
493493
self._load_child_plugins()
494494
for i, child in enumerate(self.list_children()):
495495
child_id = f"{prefix}.{i}".lstrip(".")
496+
497+
# Yield the child_id and ChildTargetRecord before attempting to open the child
498+
yield child_id, child
499+
496500
try:
497501
# Attempt to open the target for next iteration of recrusive
498502
target = self.open_child(child.path)
503+
504+
# Recursivly continue to yield these valures
505+
yield from target.list_children_recursive(prefix=child_id)
506+
499507
except TargetError:
500508
self.log.exception("Failed to open child target %s", child.path)
501509
continue
502510

503-
# Yield the child_id and ChildTargetRecord
504-
yield child_id, child
505-
506-
# Recursivly continue to yield these valures
507-
yield from target.list_children_recursive(prefix=child_id)
508511

509512
def reload(self) -> Target:
510513
"""Reload the current target.

0 commit comments

Comments
 (0)