unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Kyle Meyer <kyle@kyleam.com>
Cc: meta@public-inbox.org
Subject: [PATCH] lei_store: populate ALL.git/alternates with new epochs
Date: Mon, 22 Feb 2021 06:18:55 +0000	[thread overview]
Message-ID: <20210222061855.GA12189@dcvr> (raw)
In-Reply-To: <8735xou0gq.fsf@kyleam.com>

Kyle Meyer <kyle@kyleam.com> wrote:
> Sorry if I'm reporting a known to-do; with a quick search, I didn't spot
> anything on the list or in the code, and it feels like enough of a
> corner case to be worth mentioning.

Yikes :x  I definitely didn't notice since I'm constantly
restarting the daemon, and the test was insufficient.
Thanks for the bug report, I believe this fixes it:

-----8<-----
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 <kyle@kyleam.com>
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');
 

  reply	other threads:[~2021-02-22  6:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22  5:37 lei: accessing blob after import requires daemon restart Kyle Meyer
2021-02-22  6:18 ` Eric Wong [this message]
2021-02-22 22:47   ` [PATCH] lei_store: populate ALL.git/alternates with new epochs Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222061855.GA12189@dcvr \
    --to=e@80x24.org \
    --cc=kyle@kyleam.com \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).