use PublicInbox::Inbox;
use PublicInbox::OverIdx;
use PublicInbox::Msgmap;
-use PublicInbox::Spawn;
+use PublicInbox::Spawn qw(spawn);
+use PublicInbox::SearchIdx;
use IO::Handle;
# an estimate of the post-packed size to the raw uncompressed size
}
$v2ibx = PublicInbox::InboxWritable->new($v2ibx);
+ $v2ibx->umask_prepare;
my $xpfx = "$dir/xap" . PublicInbox::Search::SCHEMA_VERSION;
my $self = {
# mimics Import::add and wraps it for v2
sub add {
my ($self, $mime, $check_cb) = @_;
+ $self->{-inbox}->with_umask(sub {
+ _add($self, $mime, $check_cb)
+ });
+}
+
+sub _add {
+ my ($self, $mime, $check_cb) = @_;
# spam check:
if ($check_cb) {
sub remove {
my ($self, $mime, $cmt_msg) = @_;
- remove_internal($self, $mime, $cmt_msg);
+ $self->{-inbox}->with_umask(sub {
+ remove_internal($self, $mime, $cmt_msg);
+ });
}
sub purge {
my ($self, $mime) = @_;
- my $purges = remove_internal($self, $mime, undef, {});
+ my $purges = $self->{-inbox}->with_umask(sub {
+ remove_internal($self, $mime, undef, {});
+ });
$self->idx_init if @$purges; # ->done is called on purges
for my $i (0..$#$purges) {
defined(my $cmt = $purges->[$i]) or next;
sub diff ($$$) {
my ($mid, $cur, $new) = @_;
use File::Temp qw(tempfile);
- use PublicInbox::Spawn qw(spawn);
my ($ah, $an) = tempfile('email-cur-XXXXXXXX', TMPDIR => 1);
print $ah $cur->as_string or die "print: $!";
$heads;
}
-sub is_ancestor ($$$) {
- my ($git, $cur, $tip) = @_;
- return 0 unless $git->check($cur);
- my $cmd = [ 'git', "--git-dir=$git->{git_dir}",
- qw(merge-base --is-ancestor), $cur, $tip ];
- my $pid = spawn($cmd);
- defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
- waitpid($pid, 0) == $pid or die join(' ', @$cmd) .' did not finish';
- $? == 0;
-}
+*is_ancestor = *PublicInbox::SearchIdx::is_ancestor;
sub index_prepare {
my ($self, $opts, $epoch_max, $ranges) = @_;
$ranges->[$i] = $range;
# can't use 'rev-list --count' if we use --diff-filter
- my $fh = $git->popen(qw(log --pretty=tformat:%h
+ my $fh = $git->popen(qw(log --pretty=tformat:%H
--no-notes --no-color --no-renames
--diff-filter=AM), $range, '--', 'm');
++$regen_max while <$fh>;
my $regen = $self->index_prepare($opts, $epoch_max, $ranges);
$$regen += $max if $max;
my $D = {};
- my @cmd = qw(log --raw -r --pretty=tformat:%h
+ my @cmd = qw(log --raw -r --pretty=tformat:%H
--no-notes --no-color --no-abbrev --no-renames);
# work backwards through history