about summary refs log tree commit homepage
path: root/lib/PublicInbox/Import.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-17 10:19:47 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-19 20:10:41 +0000
commitff25a60b1b85c92a7e76a735a2c79c0205233a27 (patch)
treefda9bf18b9772637baaadbfbe094169cbf5800a7 /lib/PublicInbox/Import.pm
parent5a6bdba5bf610145f26243e73cd349658d2e2db9 (diff)
downloadpublic-inbox-ff25a60b1b85c92a7e76a735a2c79c0205233a27.tar.gz
Wrap the old Import package to enable creating new repos based
on size thresholds.  This is better than relying on time-based
rotation as LKML traffic seems to be increasing.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 1f831a7b..364ab602 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -31,6 +31,7 @@ sub new {
                 inbox => $ibx,
                 path_type => '2/38', # or 'v2'
                 ssoma_lock => 1, # disable for v2
+                bytes_added => 0,
         }, $class
 }
 
@@ -275,7 +276,9 @@ sub add {
 
         my $blob = $self->{mark}++;
         my $str = $mime->as_string;
-        print $w "blob\nmark :$blob\ndata ", length($str), "\n" or wfail;
+        my $n = length($str);
+        $self->{bytes_added} += $n;
+        print $w "blob\nmark :$blob\ndata ", $n, "\n" or wfail;
         print $w $str, "\n" or wfail;
         $str = undef;
 
@@ -325,7 +328,7 @@ sub add {
         $self->{tip} = ":$commit";
 }
 
-sub run_die ($$) {
+sub run_die ($;$) {
         my ($cmd, $env) = @_;
         my $pid = spawn($cmd, $env, undef);
         defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
@@ -354,7 +357,7 @@ sub done {
         }
         if ($nchg) {
                 run_die([@cmd, 'update-server-info'], undef);
-                eval {
+                ($self->{path_type} eq '2/38') and eval {
                         require PublicInbox::SearchIdx;
                         my $inbox = $self->{inbox} || $git_dir;
                         my $s = PublicInbox::SearchIdx->new($inbox);