]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_store: populate ALL.git/alternates with new epochs
authorEric Wong <e@80x24.org>
Mon, 22 Feb 2021 06:18:55 +0000 (06:18 +0000)
committerEric Wong <e@80x24.org>
Mon, 22 Feb 2021 10:31:02 +0000 (10:31 +0000)
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 <kyle@kyleam.com>
Link: https://public-inbox.org/meta/8735xou0gq.fsf@kyleam.com/
lib/PublicInbox/LeiStore.pm
t/lei-import.t

index 546d500be071c8a77b8df24efe611f526bc5a1a1..776018284b5562b8fb5af5ad0c1404e7186b8c73 100644 (file)
@@ -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};
index 46747a911657fb7e7f8ab34423b33c78b75f9d71..fa4fc5045d4d3783676b41e0c73d9f8ec7a4daf4 100644 (file)
@@ -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');