From dd80811bdaddc40520cb37abda23624674022e37 Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Sat, 7 Apr 2018 03:41:50 +0000 Subject: v2writable: reduce barriers 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. --- lib/PublicInbox/Import.pm | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'lib/PublicInbox/Import.pm') 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'); -- cgit v1.2.3-24-ge0c7