From df7e9afebf0c583640773efac01583aa9a1fa2d6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 22 Feb 2021 06:18:55 +0000 Subject: [PATCH] lei_store: populate ALL.git/alternates with new epochs Since eidx_init updates ALL.git/objects/info/alternates, we need to ensure new epochs we create from LeiStore->importer exist before eidx_init writes alternates. Reported-by: Kyle Meyer Link: https://public-inbox.org/meta/8735xou0gq.fsf@kyleam.com/ --- lib/PublicInbox/LeiStore.pm | 4 ++-- t/lei-import.t | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index 546d500b..77601828 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -192,10 +192,10 @@ sub maildir_keywords { sub add_eml { my ($self, $eml, @kw) = @_; - my $eidx = eidx_init($self); + my $im = $self->importer; # may create new epoch + my $eidx = eidx_init($self); # writes ALL.git/objects/info/alternates my $oidx = $eidx->{oidx}; my $smsg = bless { -oidx => $oidx }, 'PublicInbox::Smsg'; - my $im = $self->importer; $im->add($eml, undef, $smsg) or return; # duplicate returns undef local $self->{current_info} = $smsg->{blob}; diff --git a/t/lei-import.t b/t/lei-import.t index 46747a91..fa4fc504 100644 --- a/t/lei-import.t +++ b/t/lei-import.t @@ -13,6 +13,19 @@ lei_ok([qw(import -f eml -)], undef, { %$lei_opt, 0 => $fh }, \'import single file from stdin') or diag $lei_err; close $fh; lei_ok(qw(q s:boolean), \'search hit after import'); +lei_ok(qw(q s:boolean -f mboxrd), \'blob accessible after import'); +{ + my $expect = [ eml_load('t/data/0001.patch') ]; + require PublicInbox::MboxReader; + my @cmp; + open my $fh, '<', \$lei_out or BAIL_OUT "open :scalar: $!"; + PublicInbox::MboxReader->mboxrd($fh, sub { + my ($eml) = @_; + $eml->header_set('Status'); + push @cmp, $eml; + }); + is_deeply(\@cmp, $expect, 'got expected message in mboxrd'); +} lei_ok(qw(import -f eml), 't/data/message_embed.eml', \'import single file by path'); -- 2.50.0