]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiSavedSearch.pm
use Net::SSLeay (OpenSSL) for SHA-(1|256) if installed
[public-inbox.git] / lib / PublicInbox / LeiSavedSearch.pm
index 3e10f780ad02b6dfba449024b42468198b66f571..e53963420edde6f2e36665855c6c57781a822448 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # pretends to be like LeiDedupe and also PublicInbox::Inbox
@@ -13,7 +13,7 @@ use PublicInbox::Config;
 use PublicInbox::Spawn qw(run_die);
 use PublicInbox::ContentHash qw(git_sha);
 use PublicInbox::MID qw(mids_for_index);
-use Digest::SHA qw(sha256_hex);
+use PublicInbox::SHA qw(sha256_hex);
 our $LOCAL_PFX = qr!\A(?:maildir|mh|mbox.+|mmdf|v2):!i; # TODO: put in LeiToMail?
 
 # move this to PublicInbox::Config if other things use it:
@@ -21,6 +21,7 @@ my %cquote = ("\n" => '\\n', "\t" => '\\t', "\b" => '\\b');
 sub cquote_val ($) { # cf. git-config(1)
        my ($val) = @_;
        $val =~ s/([\n\t\b])/$cquote{$1}/g;
+       $val =~ s/\"/\\\"/g;
        $val;
 }
 
@@ -96,7 +97,7 @@ sub translate_dedupe ($$) {
        my $dd = $lei->{opt}->{dedupe} // 'content';
        return 1 if $dd eq 'content'; # the default
        return $self->{"-dedupe_$dd"} = 1 if ($dd eq 'oid' || $dd eq 'mid');
-       $lei->fail("--dedupe=$dd requires --no-save");
+       die("--dedupe=$dd requires --no-save\n");
 }
 
 sub up { # updating existing saved search via "lei up"
@@ -105,9 +106,9 @@ sub up { # updating existing saved search via "lei up"
        my $self = bless { ale => $lei->ale }, $cls;
        my $dir = $dst;
        output2lssdir($self, $lei, \$dir, \$f) or
-               return $lei->fail("--no-save was used with $dst cwd=".
-                                       $lei->rel2abs('.'));
-       $self->{-cfg} = $lei->cfg_dump($f) // return $lei->fail;
+               return die("--no-save was used with $dst cwd=".
+                                       $lei->rel2abs('.')."\n");
+       $self->{-cfg} = $lei->cfg_dump($f) // return $lei->child_error;
        $self->{-ovf} = "$dir/over.sqlite3";
        $self->{'-f'} = $f;
        $self->{lock_path} = "$self->{-f}.flock";
@@ -162,6 +163,10 @@ EOM
                my $val = $lei->{opt}->{$k} // next;
                print $fh "\t$k = $val\n";
        }
+       $lei->{opt}->{stdin} and print $fh <<EOM;
+[lei "internal"]
+       rawstr = 1 # stdin was used initially
+EOM
        close($fh) or return $lei->fail("close $f: $!");
        $self->{lock_path} = "$self->{-f}.flock";
        $self->{-ovf} = "$dir/over.sqlite3";
@@ -294,7 +299,6 @@ no warnings 'once';
 *smsg_by_mid = \&PublicInbox::Inbox::smsg_by_mid;
 *msg_by_mid = \&PublicInbox::Inbox::msg_by_mid;
 *modified = \&PublicInbox::Inbox::modified;
-*recent = \&PublicInbox::Inbox::recent;
 *max_git_epoch = *nntp_usable = *msg_by_path = \&mm; # undef
 *isrch = *search = \&mm; # TODO
 *DESTROY = \&pause_dedupe;