]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxShard.pm
searchidxshard: further improve {current_info} readability
[public-inbox.git] / lib / PublicInbox / SearchIdxShard.pm
index 644d8b58e65883c55ea09b4f780ba4736b2a9028..1333b30529e857b5fb205dc4b24e0c8275b30e66 100644 (file)
@@ -87,8 +87,9 @@ sub shard_worker_loop ($$$$$) {
                } else {
                        chomp $line;
                        my $eidx_key;
-                       if ($line =~ s/\AX(.+)\0//) {
+                       if ($line =~ s/\AX=(.+)\0//) {
                                $eidx_key = $1;
+                               $v2w->{current_info} =~ s/\0/\\0 /;
                        }
                        # n.b. $mid may contain spaces(!)
                        my ($len, $bytes, $num, $oid, $ds, $ts, $tid, $mid)
@@ -113,14 +114,11 @@ sub shard_worker_loop ($$$$$) {
 sub index_raw {
        my ($self, $msgref, $eml, $smsg, $ibx) = @_;
        if (my $w = $self->{w}) {
-               if ($ibx) {
-                       print $w 'X', $ibx->eidx_key, "\0" or die
-                               "failed to write shard: $!\n";
-               }
+               my @ekey = $ibx ? ('X='.$ibx->eidx_key."\0") : ();
                $msgref //= \($eml->as_string);
                $smsg->{raw_bytes} //= length($$msgref);
                # mid must be last, it can contain spaces (but not LF)
-               print $w join(' ', @$smsg{qw(raw_bytes bytes
+               print $w @ekey, join(' ', @$smsg{qw(raw_bytes bytes
                                                num blob ds ts tid mid)}),
                        "\n", $$msgref or die "failed to write shard $!\n";
        } else {