From 8e81d6f0d44198717ae540421a09824d75c9bb6d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 20 Mar 2020 08:18:13 +0000 Subject: index: use git commit times on missing Date/Received 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. --- lib/PublicInbox/OverIdx.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/OverIdx.pm') 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); } -- cgit v1.2.3-24-ge0c7