From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 770E91F9F4 for ; Wed, 10 Nov 2021 10:28:37 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] lei up: infer rawstr from old searches via trailing "\n" Date: Wed, 10 Nov 2021 10:28:37 +0000 Message-Id: <20211110102837.41721-1-e@80x24.org> In-Reply-To: <20211110102511.40960-1-e@80x24.org> References: <20211110102511.40960-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: For --stdin searches created prior to commit 666dde69a3f6 (lei q|up: fix saved searches for single-phrase search, 2021-11-08) we still want to be able to run "lei up" on them without regressions. So assume nobody manages to enter "\n" as an argv[] element and consider the presence of "\n" as a previous --stdin use. This fixes errors from "lei up" such as: lei_xsearch 2 wq_worker: Exception: Key too long: length was 840 bytes, maximum length of a key is 255 bytes at ../PublicInbox/IPC.pm line 250. Fixes: 666dde69a3f6 ("lei q|up: fix saved searches for single-phrase search") --- lib/PublicInbox/LeiUp.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm index d7873a3f3469..b8a9836075ba 100644 --- a/lib/PublicInbox/LeiUp.pm +++ b/lib/PublicInbox/LeiUp.pm @@ -29,7 +29,9 @@ sub up1 ($$) { my $q = $lss->{-cfg}->get_all('lei.q') // die("lei.q unset in $f (out=$out)\n"); my $lse = $lei->{lse} // die 'BUG: {lse} missing'; - if ($lss->{-cfg}->{'lei.internal.rawstr'}) { + my $rawstr = $lss->{-cfg}->{'lei.internal.rawstr'} // + (scalar(@$q) == 1 && substr($q->[0], -1) eq "\n"); + if ($rawstr) { scalar(@$q) > 1 and die "$f: lei.q has multiple values (@$q) (out=$out)\n"; $lse->query_approxidate($lse->git, $mset_opt->{qstr} = $q->[0]);