# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# This interface wraps and mimics PublicInbox::Import
+# Used to write to V2 inboxes (see L<public-inbox-v2-format(5)>).
package PublicInbox::V2Writable;
use strict;
use warnings;
return if $existing;
}
+ # AltId may pre-populate article numbers (e.g. X-Mail-Count
+ # or NNTP article number), use that article number if it's
+ # not in Over.
+ my $altid = $self->{-inbox}->{altid};
+ if ($altid && grep(/:file=msgmap\.sqlite3\z/, @$altid)) {
+ my $num = $self->{mm}->num_for($mid);
+
+ if (defined $num && !$self->{over}->get_art($num)) {
+ $$mid0 = $mid;
+ return $num;
+ }
+ }
+
# very unlikely:
warn "<$mid> reused for mismatched content\n";
# frequently activated.
delete $ibx->{$_} foreach (qw(git mm search));
- if ($self->{parallel}) {
- pipe(my ($r, $w)) or die "pipe failed: $!";
- $self->{bnote} = [ $r, $w ];
- $w->autoflush(1);
- }
+ my $indexlevel = $ibx->{indexlevel};
+ if ($indexlevel && $indexlevel eq 'basic') {
+ $self->{parallel} = 0;
+ }
+
+ if ($self->{parallel}) {
+ pipe(my ($r, $w)) or die "pipe failed: $!";
+ # pipe for barrier notifications doesn't need to be big,
+ # 1031: F_SETPIPE_SZ
+ fcntl($w, 1031, 4096) if $^O eq 'linux';
+ $self->{bnote} = [ $r, $w ];
+ $w->autoflush(1);
+ }
my $over = $self->{over};
$ibx->umask_prepare;
my $git_dir = git_dir_n($self, $i);
-d $git_dir or next; # missing parts are fine
my $git = PublicInbox::Git->new($git_dir);
- chomp(my $tip = $git->qx('rev-parse', $head));
+ chomp(my $tip = $git->qx(qw(rev-parse -q --verify), $head));
+ next if $?; # new repo
my $range;
if (defined(my $cur = $ranges->[$i])) {
$range = "$cur..$tip";