]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiXSearch.pm
lei q: one -t shouldn't set `flagged' on external mail
[public-inbox.git] / lib / PublicInbox / LeiXSearch.pm
index 458151801b8c1eaf6179325cba637501c416f603..f2c8c02e8c653c7d670128093a31d0d4c7049c93 100644 (file)
@@ -92,7 +92,7 @@ sub recent {
        my ($self, $qstr, $opt) = @_;
        $opt //= {};
        $opt->{relevance} //= -2;
-       $self->mset($qstr //= 'bytes:1..', $opt);
+       $self->mset($qstr //= 'z:1..', $opt);
 }
 
 sub over {}
@@ -148,7 +148,7 @@ sub query_thread_mset { # for --threads
        my $mset;
        my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei, $ibxish);
        my $can_kw = !!$ibxish->can('msg_keywords');
-       my $fl = $lei->{opt}->{threads} > 1;
+       my $fl = $lei->{opt}->{threads} > 1 ? [ 'flagged' ] : undef;
        do {
                $mset = $srch->mset($mo->{qstr}, $mo);
                mset_progress($lei, $desc, $mset->size,
@@ -165,8 +165,8 @@ sub query_thread_mset { # for --threads
                                if ($mitem) {
                                        if ($can_kw) {
                                                mitem_kw($smsg, $mitem, $fl);
-                                       } else {
-                                               $smsg->{kw} = [ 'flagged' ];
+                                       } elsif ($fl) {
+                                               $smsg->{kw} = $fl;
                                        }
                                }
                                $each_smsg->($smsg, $mitem);
@@ -416,6 +416,11 @@ sub ipc_atfork_child {
        $self->SUPER::ipc_atfork_child;
 }
 
+sub delete_pkt_op { # OnDestroy callback
+       my $unclosed_after_die = delete($_[0])->{pkt_op_p} or return;
+       close $unclosed_after_die;
+}
+
 sub do_query {
        my ($self, $lei) = @_;
        my $l2m = $lei->{l2m};
@@ -431,6 +436,7 @@ sub do_query {
                'incr_start_query' => [ \&incr_start_query, $self, $l2m ],
        };
        $lei->{auth}->op_merge($ops, $l2m) if $l2m && $lei->{auth};
+       my $od = PublicInbox::OnDestroy->new($$, \&delete_pkt_op, $lei);
        ($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops);
        $lei->{1}->autoflush(1);
        $lei->start_pager if delete $lei->{need_pager};