unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/2] lei bugfixes
@ 2023-12-16 11:13 Eric Wong
  2023-12-16 11:13 ` [PATCH 1/2] lei index: support +L: labels Eric Wong
  2023-12-16 11:13 ` [PATCH 2/2] lei: use ->child_error API properly Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2023-12-16 11:13 UTC (permalink / raw)
  To: meta

Eric Wong (2):
  lei index: support +L: labels
  lei: use ->child_error API properly

 lib/PublicInbox/LEI.pm         | 2 +-
 lib/PublicInbox/LeiExportKw.pm | 4 ++--
 lib/PublicInbox/LeiMirror.pm   | 2 +-
 lib/PublicInbox/LeiToMail.pm   | 4 ++--
 t/lei-index.t                  | 3 ++-
 5 files changed, 8 insertions(+), 7 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] lei index: support +L: labels
  2023-12-16 11:13 [PATCH 0/2] lei bugfixes Eric Wong
@ 2023-12-16 11:13 ` Eric Wong
  2023-12-16 11:13 ` [PATCH 2/2] lei: use ->child_error API properly Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2023-12-16 11:13 UTC (permalink / raw)
  To: meta

`lei index' should be capable of indexing the the same way
`lei import' does, but without the indexing.  I only noticed
this omission while developing a new feature.
---
 lib/PublicInbox/LEI.pm | 2 +-
 t/lei-index.t          | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index a89bdc51..17431518 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -259,7 +259,7 @@ tag => [ 'KEYWORDS... LOCATION...|--stdin',
 
 'reindex' => [ '', 'reindex all locally-indexed messages', @c_opt ],
 
-'index' => [ 'LOCATION...', 'one-time index from URL or filesystem',
+'index' => [ 'LOCATION... [LABELS...]', 'one-time index from URL or filesystem',
 	qw(in-format|F=s kw! offset=i recursive|r exclude=s include|I=s
 	verbose|v+ incremental!), @net_opt, # mainly for --proxy=
 	 @c_opt ],
diff --git a/t/lei-index.t b/t/lei-index.t
index c31b1c3c..2b28f1be 100644
--- a/t/lei-index.t
+++ b/t/lei-index.t
@@ -48,9 +48,10 @@ symlink(File::Spec->rel2abs('t/mda-mime.eml'), "$tmpdir/md1/cur/x:2,S") or
 test_lei({ tmpdir => $tmpdir }, sub {
 	my $store_path = "$ENV{HOME}/.local/share/lei/store/";
 
-	lei_ok('index', "$tmpdir/md");
+	lei_ok qw(index +L:md), "$tmpdir/md";
 	lei_ok(qw(q mid:qp@example.com));
 	my $res_a = json_utf8->decode($lei_out);
+	is_deeply $res_a->[0]->{L}, [ 'md' ], 'label set on index';
 	my $blob = $res_a->[0]->{'blob'};
 	like($blob, qr/\A[0-9a-f]{40,}\z/, 'got blob from qp@example');
 	lei_ok(qw(-C / blob), $blob);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] lei: use ->child_error API properly
  2023-12-16 11:13 [PATCH 0/2] lei bugfixes Eric Wong
  2023-12-16 11:13 ` [PATCH 1/2] lei index: support +L: labels Eric Wong
@ 2023-12-16 11:13 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2023-12-16 11:13 UTC (permalink / raw)
  To: meta

I noticed this bug while developing another feature and tests
were getting SIGHUP (since SIGHUP == 1 on most systems).
---
 lib/PublicInbox/LeiExportKw.pm | 4 ++--
 lib/PublicInbox/LeiMirror.pm   | 2 +-
 lib/PublicInbox/LeiToMail.pm   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm
index d2396fa7..16f069da 100644
--- a/lib/PublicInbox/LeiExportKw.pm
+++ b/lib/PublicInbox/LeiExportKw.pm
@@ -38,7 +38,7 @@ sub export_kw_md { # LeiMailSync->each_src callback
 		} elsif ($! == EEXIST) { # lost race with lei/store?
 			return;
 		} elsif ($! != ENOENT) {
-			$lei->child_error(1,
+			$lei->child_error(0,
 				"E: rename_noreplace($src -> $dst): $!");
 		} # else loop @try
 	}
@@ -46,7 +46,7 @@ sub export_kw_md { # LeiMailSync->each_src callback
 	# both tries failed
 	my $oidhex = unpack('H*', $oidbin);
 	my $src = "$mdir/{".join(',', @try)."}/$$id";
-	$lei->child_error(1, "rename_noreplace($src -> $dst) ($oidhex): $e");
+	$lei->child_error(0, "rename_noreplace($src -> $dst) ($oidhex): $e");
 	for (@try) { return if -e "$mdir/$_/$$id" }
 	$self->{lms}->clear_src("maildir:$mdir", $id);
 }
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index 0c77a8b5..5353ae61 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -1175,7 +1175,7 @@ sub try_manifest {
 	local $self->{-local_manifest} = load_current_manifest($self);
 	local $self->{-new_symlinks} = [];
 	my ($path_pfx, $n, $multi) = multi_inbox($self, \$path, $m);
-	return $lei->child_error(1, $multi) if !ref($multi);
+	return $lei->child_error(0, $multi) if !ref($multi);
 	my $v2 = delete $multi->{v2};
 	if ($v2) {
 		for my $name (sort keys %$v2) {
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index a930fc30..071ba113 100644
--- a/lib/PublicInbox/LeiToMail.pm
+++ b/lib/PublicInbox/LeiToMail.pm
@@ -147,9 +147,9 @@ sub git_to_mail { # git->cat_async callback
 			$type = 'blob';
 			$size = length($$bref);
 		}
-		$type eq 'blob' or return $self->{lei}->child_error(1,
+		$type eq 'blob' or return $self->{lei}->child_error(0,
 						"W: $oid is $type (!= blob)");
-		$size or return $self->{lei}->child_error(1,"E: $oid is empty");
+		$size or return $self->{lei}->child_error(0,"E: $oid is empty");
 		$smsg->{blob} eq $oid or die "BUG: expected=$smsg->{blob}";
 		$self->{wcb}->($bref, $smsg);
 	};

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-16 11:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-16 11:13 [PATCH 0/2] lei bugfixes Eric Wong
2023-12-16 11:13 ` [PATCH 1/2] lei index: support +L: labels Eric Wong
2023-12-16 11:13 ` [PATCH 2/2] lei: use ->child_error API properly Eric Wong

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).