diff options
author | Eric Wong <e@yhbt.net> | 2020-03-20 08:18:13 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-03-22 09:00:23 +0000 |
commit | 8e81d6f0d44198717ae540421a09824d75c9bb6d (patch) | |
tree | 754d15673307a90dcba5aa4cb088f7cbcd2ece49 /lib/PublicInbox/OverIdx.pm | |
parent | c29b2b7ded47def906cf00e3baad65c102304120 (diff) | |
download | public-inbox-8e81d6f0d44198717ae540421a09824d75c9bb6d.tar.gz |
When indexing messages without Date: and/or Received: headers, fall back to using timestamps originally recorded by git in the commit object. This allows git mirrors to preserve the import datestamp and timestamp of a message according to what was fed into git, instead of blindly falling back to the current time.
Diffstat (limited to 'lib/PublicInbox/OverIdx.pm')
-rw-r--r-- | lib/PublicInbox/OverIdx.pm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index 0549c68b..9ee6d613 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -15,6 +15,7 @@ use IO::Handle; use DBI qw(:sql_types); # SQL_BLOB use PublicInbox::MID qw/id_compress mids_for_index references/; use PublicInbox::SearchMsg qw(subject_normalized); +use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp); use Compress::Zlib qw(compress); use PublicInbox::Search; @@ -246,7 +247,7 @@ sub subject_path ($) { } sub add_overview { - my ($self, $mime, $bytes, $num, $oid, $mid0) = @_; + my ($self, $mime, $bytes, $num, $oid, $mid0, $times) = @_; my $lines = $mime->body_raw =~ tr!\n!\n!; my $smsg = bless { mime => $mime, @@ -255,7 +256,8 @@ sub add_overview { lines => $lines, blob => $oid, }, 'PublicInbox::SearchMsg'; - my $mids = mids_for_index($mime->header_obj); + my $hdr = $mime->header_obj; + my $mids = mids_for_index($hdr); my $refs = parse_references($smsg, $mid0, $mids); my $subj = $smsg->subject; my $xpath; @@ -266,7 +268,9 @@ sub add_overview { my $dd = $smsg->to_doc_data($oid, $mid0); utf8::encode($dd); $dd = compress($dd); - my $values = [ $smsg->ts, $smsg->ds, $num, $mids, $refs, $xpath, $dd ]; + my $ds = msg_timestamp($hdr, $times->{autime}); + my $ts = msg_datestamp($hdr, $times->{cotime}); + my $values = [ $ts, $ds, $num, $mids, $refs, $xpath, $dd ]; add_over($self, $values); } |