-sub seq_fetch_m { # long_response
- my ($self, $tag, $msgs, $range_info, $want) = @_;
- while (!@$msgs) { # rare
- if (my $end = refill_range($self, $msgs, $range_info)) {
- $self->write(\"$tag $end\r\n");
- return;
- }
- }
- my $seq = $want->{-seqno}++;
- my $cur_num = $msgs->[0]->{num};
- if ($cur_num == $seq) { # as expected
- git_async_cat($self->{ibx}->git, $msgs->[0]->{blob},
- \&uid_fetch_cb, \@_);
- } elsif ($cur_num > $seq) {
- # send dummy messages until $seq catches up to $cur_num
- my $smsg = bless { num => $seq, ts => 0 }, 'PublicInbox::Smsg';
- unshift @$msgs, $smsg;
- my $bref = dummy_message($self, $seq);
- uid_fetch_cb($bref, undef, undef, undef, \@_);
- $smsg; # blessed response since uid_fetch_cb requeues
- } else { # should not happen
- die "BUG: cur_num=$cur_num < seq=$seq";
- }
-}
-
-sub cmd_fetch ($$$;@) {
- my ($self, $tag, $range_csv, @want) = @_;
- my $args = fetch_common($self, $tag, $range_csv, \@want);
- ref($args) eq 'ARRAY' ? do {
- my $want = $args->[-1];
- $want->{-seqno} = $args->[2]->[0]; # $beg == $range_info->[0];
- long_response($self, \&seq_fetch_m, @$args)
- } : $args; # error
-}
-
-