]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
spawn (and thus popen_rd) die on failure
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index ab80941acb64431537b54029613bb42d62776f71..5179432617a561a1d034f550de06b3462c8b0b02 100644 (file)
@@ -18,7 +18,7 @@ use PublicInbox::OverIdx;
 use PublicInbox::Msgmap;
 use PublicInbox::Spawn qw(spawn);
 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
@@ -62,10 +62,13 @@ sub count_shards ($) {
        # 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++;
                        };
                }
@@ -470,7 +473,7 @@ sub git_hash_raw ($$) {
 
        my ($r, $w);
        pipe($r, $w) or die "failed to create pipe: $!";
-       my $rdr = { 0 => fileno($tmp_fh), 1 => fileno($w) };
+       my $rdr = { 0 => $tmp_fh, 1 => $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);
@@ -774,7 +777,6 @@ sub diff ($$$) {
        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);
 }