about summary refs log tree commit homepage
path: root/lib/PublicInbox/Eml.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:09 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commitca68e519d588b1fd97d9d4a9c43bbb07534624c2 (patch)
tree5d8c68d595a1e5a9bdff2df0926d7f461afe7e23 /lib/PublicInbox/Eml.pm
parentb5217ee1eee64ff22e085c9eb942b5ea65da9bd9 (diff)
downloadpublic-inbox-ca68e519d588b1fd97d9d4a9c43bbb07534624c2.tar.gz
I'm not sure which clients use these, but it could be useful
down the line.
Diffstat (limited to 'lib/PublicInbox/Eml.pm')
-rw-r--r--lib/PublicInbox/Eml.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm
index 6f6874cd..d2bd3915 100644
--- a/lib/PublicInbox/Eml.pm
+++ b/lib/PublicInbox/Eml.pm
@@ -235,11 +235,11 @@ sub mp_descend ($$) {
 # $arg - user-supplied arg (think pthread_create)
 # $once - unref body scalar during iteration
 sub each_part {
-        my ($self, $cb, $arg, $once) = @_;
+        my ($self, $cb, $arg, $once, $all) = @_;
         my $p = mp_descend($self, $once // 0) or
                                         return $cb->([$self, 0, 0], $arg);
 
-        $cb->([$self, 0, 0], $arg) if $self->{-call_cb}; # rare
+        $cb->([$self, 0, 0], $arg) if ($all || $self->{-call_cb}); # rare
 
         $p = [ $p, 0 ];
         my @s; # our virtual stack
@@ -255,7 +255,8 @@ sub each_part {
                                 (my $nxt = mp_descend($sub, $nr))) {
                         push(@s, $p) if scalar @{$p->[0]};
                         $p = [ $nxt, @idx, 0 ];
-                        $cb->([$sub, $depth, @idx], $arg) if $sub->{-call_cb};
+                        ($all || $sub->{-call_cb}) and
+                                $cb->([$sub, $depth, @idx], $arg);
                 } else { # a leaf node
                         $cb->([$sub, $depth, @idx], $arg);
                 }