]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
wwwstream: use parent.pm and no warnings
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 913794316330bbc261d6f236f0e5a355c5b11ec5..528f5e9a5650df2866b60e5ad602306a8c0eda37 100644 (file)
@@ -113,6 +113,7 @@ sub new {
                im => undef, #  PublicInbox::Import
                parallel => 1,
                transact_bytes => 0,
+               total_bytes => 0,
                current_info => '',
                xpfx => $xpfx,
                over => PublicInbox::OverIdx->new("$xpfx/over.sqlite3", 1),
@@ -128,12 +129,13 @@ sub new {
 
 # public (for now?)
 sub init_inbox {
-       my ($self, $shards, $skip_epoch) = @_;
+       my ($self, $shards, $skip_epoch, $skip_artnum) = @_;
        if (defined $shards) {
                $self->{parallel} = 0 if $shards == 0;
                $self->{shards} = $shards if $shards > 0;
        }
        $self->idx_init;
+       $self->{mm}->skip_artnum($skip_artnum) if defined $skip_artnum;
        my $epoch_max = -1;
        git_dir_latest($self, \$epoch_max);
        if (defined $skip_epoch && $epoch_max == -1) {
@@ -169,7 +171,7 @@ sub _add {
 
        # spam check:
        if ($check_cb) {
-               $mime = $check_cb->($mime) or return;
+               $mime = $check_cb->($mime, $self->{-inbox}) or return;
        }
 
        # All pipes (> $^F) known to Perl 5.6+ have FD_CLOEXEC set,
@@ -658,6 +660,7 @@ sub checkpoint ($;$) {
 
                $dbh->begin_work;
        }
+       $self->{total_bytes} += $self->{transact_bytes};
        $self->{transact_bytes} = 0;
 }
 
@@ -680,8 +683,9 @@ sub done {
        }
        $self->{over}->disconnect;
        delete $self->{bnote};
-       $self->{transact_bytes} = 0;
-       $self->lock_release if $shards;
+       my $nbytes = $self->{total_bytes};
+       $self->{total_bytes} = 0;
+       $self->lock_release(!!$nbytes) if $shards;
        $self->{-inbox}->git->cleanup;
 }