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-04-07 03:41:50 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-07 03:42:27 +0000
commitdd80811bdaddc40520cb37abda23624674022e37 (patch)
treea724846f2373fc0e9ad78049ba2d32d9ab8cf8f3 /lib/PublicInbox/Import.pm
parent06cd576bb9b73eb177728fead06de8c3fac8d7a3 (diff)
downloadpublic-inbox-dd80811bdaddc40520cb37abda23624674022e37.tar.gz
Since we handle the overview info synchronously, we only need
barriers in tests, now.  We will use asynchronous checkpoints
to sync less-important Xapian data.

For data deduplication, this requires us to hoist out the
cat-blob support in ::Import for reading uncommitted data
in git.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm34
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 2529798f..9e8900f3 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -95,19 +95,13 @@ sub _check_path ($$$$) {
         $info =~ /\Amissing / ? undef : $info;
 }
 
-sub check_remove_v1 {
-        my ($r, $w, $tip, $path, $mime) = @_;
-
-        my $info = _check_path($r, $w, $tip, $path) or return ('MISSING',undef);
-        $info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info";
-        my $blob = $1;
-
-        print $w "cat-blob $blob\n" or wfail;
+sub _cat_blob ($$$) {
+        my ($r, $w, $oid) = @_;
+        print $w "cat-blob $oid\n" or wfail;
         local $/ = "\n";
-        $info = <$r>;
+        my $info = <$r>;
         defined $info or die "EOF from fast-import / cat-blob: $!";
-        $info =~ /\A[a-f0-9]{40} blob (\d+)\n\z/ or
-                                die "unexpected cat-blob response: $info";
+        $info =~ /\A[a-f0-9]{40} blob (\d+)\n\z/ or return;
         my $left = $1;
         my $offset = 0;
         my $buf = '';
@@ -122,7 +116,23 @@ sub check_remove_v1 {
         $n = read($r, my $lf, 1);
         defined($n) or die "read final byte of cat-blob failed: $!";
         die "bad read on final byte: <$lf>" if $lf ne "\n";
-        my $cur = PublicInbox::MIME->new(\$buf);
+        \$buf;
+}
+
+sub cat_blob {
+        my ($self, $oid) = @_;
+        my ($r, $w) = $self->gfi_start;
+        _cat_blob($r, $w, $oid);
+}
+
+sub check_remove_v1 {
+        my ($r, $w, $tip, $path, $mime) = @_;
+
+        my $info = _check_path($r, $w, $tip, $path) or return ('MISSING',undef);
+        $info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info";
+        my $oid = $1;
+        my $msg = _cat_blob($r, $w, $oid) or die "BUG: cat-blob $1 failed";
+        my $cur = PublicInbox::MIME->new($msg);
         my $cur_s = $cur->header('Subject');
         $cur_s = '' unless defined $cur_s;
         my $cur_m = $mime->header('Subject');