]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
favor git(1) rather than libgit2 for ExtSearch
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index 2af5ab0c530fc28b382db4d5f2dbaded26d245e9..9402aa41fe4fe94ddbb722ca534c4df4ee56c90f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Each instance of this represents an IMAP client connected to
@@ -499,7 +499,7 @@ sub body_disposition ($) {
        my $cd = $eml->header_raw('Content-Disposition') or return 'NIL';
        $cd = parse_content_disposition($cd);
        my $buf = '('._esc($cd->{type});
-       $buf .= ' ' . _esc_hash(delete $cd->{attributes});
+       $buf .= ' ' . _esc_hash($cd->{attributes});
        $buf .= ')';
 }
 
@@ -511,7 +511,7 @@ sub body_leaf ($$;$) {
        my $ct = $eml->ct;
        $buf .= '('._esc($ct->{type}).' ';
        $buf .= _esc($ct->{subtype});
-       $buf .= ' ' . _esc_hash(delete $ct->{attributes});
+       $buf .= ' ' . _esc_hash($ct->{attributes});
        $buf .= ' ' . _esc($eml->header_raw('Content-ID'));
        $buf .= ' ' . _esc($eml->header_raw('Content-Description'));
        my $cte = $eml->header_raw('Content-Transfer-Encoding') // '7bit';
@@ -540,7 +540,7 @@ sub body_parent ($$$) {
                $buf .= @$hold ? join('', @$hold) : 'NIL';
                $buf .= ' '._esc($ct->{subtype});
                if ($structure) {
-                       $buf .= ' '._esc_hash(delete $ct->{attributes});
+                       $buf .= ' '._esc_hash($ct->{attributes});
                        $buf .= ' '.body_disposition($eml);
                        $buf .= ' '._esc($eml->header_raw('Content-Language'));
                        $buf .= ' '._esc($eml->header_raw('Content-Location'));
@@ -612,7 +612,7 @@ sub fetch_run_ops {
        $self->msg_more(")\r\n");
 }
 
-sub fetch_blob_cb { # called by git->cat_async via git_async_cat
+sub fetch_blob_cb { # called by git->cat_async via ibx_async_cat
        my ($bref, $oid, $type, $size, $fetch_arg) = @_;
        my ($self, undef, $msgs, $range_info, $ops, $partial) = @$fetch_arg;
        my $ibx = $self->{ibx} or return $self->close; # client disconnected
@@ -627,8 +627,8 @@ sub fetch_blob_cb { # called by git->cat_async via git_async_cat
        }
        my $pre;
        if (!$self->{wbuf} && (my $nxt = $msgs->[0])) {
-               $pre = git_async_prefetch($ibx->git, $nxt->{blob},
-                                               \&fetch_blob_cb, $fetch_arg);
+               $pre = ibx_async_prefetch($ibx, $nxt->{blob},
+                                       \&fetch_blob_cb, $fetch_arg);
        }
        fetch_run_ops($self, $smsg, $bref, $ops, $partial);
        $pre ? $self->zflush : requeue_once($self);
@@ -760,7 +760,7 @@ sub fetch_blob { # long_response
                }
        }
        uo2m_extend($self, $msgs->[-1]->{num});
-       git_async_cat($self->{ibx}->git, $msgs->[0]->{blob},
+       ibx_async_cat($self->{ibx}, $msgs->[0]->{blob},
                        \&fetch_blob_cb, \@_);
 }
 
@@ -1142,7 +1142,7 @@ sub search_common {
                };
                my $mset = $srch->mset($q, $opt);
                my $uids = $srch->mset_to_artnums($mset, $opt);
-               msn_convert($self, $uids) if $want_msn;
+               msn_convert($self, $uids) if scalar(@$uids) && $want_msn;
                "* SEARCH @$uids\r\n$tag OK Search done\r\n";
        } else {
                "$tag BAD Error\r\n";
@@ -1228,7 +1228,7 @@ sub long_step {
        } elsif ($more) { # $self->{wbuf}:
                $self->update_idle_time;
 
-               # control passed to git_async_cat if $more == \undef
+               # control passed to ibx_async_cat if $more == \undef
                requeue_once($self) if !ref($more);
        } else { # all done!
                delete $self->{long_cb};