use PublicInbox::Inbox;
use PublicInbox::OverIdx;
use PublicInbox::Msgmap;
-use PublicInbox::Spawn qw(spawn);
+use PublicInbox::Spawn qw(spawn popen_rd);
use PublicInbox::SearchIdx;
-use IO::Handle;
+use IO::Handle; # ->autoflush
use File::Temp qw(tempfile);
# an estimate of the post-packed size to the raw uncompressed size
# Also, shard count may change while -watch is running
# due to "xcpdb --reshard"
if (-d $xpfx) {
+ require PublicInbox::Search;
+ PublicInbox::Search::load_xapian();
+ my $XapianDatabase = $PublicInbox::Search::X{Database};
foreach my $shard (<$xpfx/*>) {
-d $shard && $shard =~ m!/[0-9]+\z! or next;
eval {
- Search::Xapian::Database->new($shard)->close;
+ $XapianDatabase->new($shard)->close;
$n++;
};
}
# $creat may be any true value, or 0/undef. A hashref is true,
# and $creat->{nproc} may be set to an integer
my ($class, $v2ibx, $creat) = @_;
- my $dir = $v2ibx->{inboxdir} or die "no inboxdir in inbox\n";
+ $v2ibx = PublicInbox::InboxWritable->new($v2ibx);
+ my $dir = $v2ibx->assert_usable_dir;
unless (-d $dir) {
if ($creat) {
require File::Path;
die "$dir does not exist\n";
}
}
-
- $v2ibx = PublicInbox::InboxWritable->new($v2ibx);
$v2ibx->umask_prepare;
my $xpfx = "$dir/xap" . PublicInbox::Search::SCHEMA_VERSION;
print $tmp_fh $$raw or die "print \$tmp_fh: $!";
sysseek($tmp_fh, 0, 0) or die "seek failed: $!";
- my ($r, $w);
- pipe($r, $w) or die "failed to create pipe: $!";
- my $rdr = { 0 => fileno($tmp_fh), 1 => fileno($w) };
my $git_dir = $self->{-inbox}->git->{git_dir};
my $cmd = ['git', "--git-dir=$git_dir", qw(hash-object --stdin)];
- my $pid = spawn($cmd, undef, $rdr);
- close $w;
+ my $r = popen_rd($cmd, undef, { 0 => $tmp_fh });
local $/ = "\n";
chomp(my $oid = <$r>);
- waitpid($pid, 0) == $pid or die "git hash-object did not finish";
- die "git hash-object failed: $?" if $?;
+ close $r or die "git hash-object failed: $?";
$oid =~ /\A[a-f0-9]{40}\z/ or die "OID not expected: $oid";
$oid;
}
my $cmd = [ qw(diff -u), $an, $bn ];
print STDERR "# MID conflict <$mid>\n";
my $pid = spawn($cmd, undef, { 1 => 2 });
- defined $pid or die "diff failed to spawn $!";
waitpid($pid, 0) == $pid or die "diff did not finish";
unlink($an, $bn);
}
--no-notes --no-color --no-renames
--diff-filter=AM), $range, '--', 'm');
++$n while <$fh>;
+ close $fh or die "git log failed: \$?=$?";
$pr->("$n\n") if $pr;
$regen_max += $n;
}
unindex_oid($self, $git, $1, $unindexed);
}
delete $self->{reindex_pipe};
- $fh = undef;
+ close $fh or die "git log failed: \$?=$?";
return unless $sync->{-opt}->{prune};
my $after = scalar keys %$unindexed;
# ensure any blob can not longer be accessed via dumb HTTP
PublicInbox::Import::run_die(['git', "--git-dir=$git->{git_dir}",
- qw(-c gc.reflogExpire=now gc --prune=all)]);
+ qw(-c gc.reflogExpire=now gc --prune=all --quiet)]);
}
sub sync_ranges ($$$) {
mark_deleted($self, $sync, $git, $1);
}
}
- $fh = undef;
+ close $fh or die "git log failed: \$?=$?";
delete $self->{reindex_pipe};
update_last_commit($self, $git, $i, $cmt) if defined $cmt;
}