]>
diplodocus.org Git - minc/blob - msgiddb
5 B<msgiddb> - update database mapping Message-ID to message file names
9 B<msgiddb> I<dbfile> I<message-files>
13 For each I<message-file>, read its Message-ID and use as key in I<dbfile>.
14 Check for its presence in the JSON-serialized list stored as the value;
15 if absent, append and update the db.
17 For messages with multiple Message-ID fields, concatenate all the values and use
20 I<message-file> names are used exactly; no path components are stripped.
30 use List
::Util
'first';
33 use lib
$FindBin::Bin
;
41 my $current_value = $db->{$key};
44 $values = decode_json
($current_value);
45 if ( first
{ defined($_) } @$values ) {
53 push( @$values, $value );
54 $db->{$key} = encode_json
($values);
59 tie
( my %db, 'DB_File', $dbfn ) or die("tie(DB_File, $dbfn): $!");
63 my $msgids = get_headers
($fn)->{'message-id'};
64 if ( !( defined($msgids) && @$msgids ) ) {
65 say STDERR
"$fn has no message-id";
69 my $msgid = join( '', @$msgids );
70 push_dblist
( \
%db, $msgid, $fn );