about summary refs log tree commit homepage
path: root/lib/PublicInbox/Import.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-03-20 08:18:14 +0000
committerEric Wong <e@yhbt.net>2020-03-22 09:00:23 +0000
commite5dbf0680cfbfa81bad38457c0430fd260dda682 (patch)
tree4e4ef95e5b5ece80e4976a006f0d645bd3368f66 /lib/PublicInbox/Import.pm
parent8e81d6f0d44198717ae540421a09824d75c9bb6d (diff)
downloadpublic-inbox-e5dbf0680cfbfa81bad38457c0430fd260dda682.tar.gz
While v2 indexing is triggered immediately after writing the
commit to the git repository, there may be a gap between when
PublicInbox::Import generates a timestamp and when
PublicInbox::SearchIdx sees the message.  So follow the mirror
indexing behavior and take the to-be-indexed (time|date)stamps
directly from the git commit.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 68dc0c7e..3853ff2b 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -274,8 +274,8 @@ sub git_timestamp {
         "$ts $zone";
 }
 
-sub extract_cmt_info ($) {
-        my ($mime) = @_;
+sub extract_cmt_info ($;$) {
+        my ($mime, $v2w) = @_;
 
         my $sender = '';
         my $from = $mime->header('From');
@@ -325,6 +325,10 @@ sub extract_cmt_info ($) {
         utf8::encode($subject);
         my $at = git_timestamp(my @at = msg_datestamp($hdr));
         my $ct = git_timestamp(my @ct = msg_timestamp($hdr));
+        if ($v2w) { # set fallbacks in case message had no date
+                $v2w->{autime} = $at[0];
+                $v2w->{cotime} = $ct[0];
+        }
         ($name, $email, $at, $ct, $subject);
 }
 
@@ -370,9 +374,9 @@ sub clean_tree_v2 ($$$) {
 # returns undef on duplicate
 # returns the :MARK of the most recent commit
 sub add {
-        my ($self, $mime, $check_cb) = @_; # mime = Email::MIME
+        my ($self, $mime, $check_cb, $v2w) = @_; # mime = Email::MIME
 
-        my ($name, $email, $at, $ct, $subject) = extract_cmt_info($mime);
+        my ($name, $email, $at, $ct, $subject) = extract_cmt_info($mime, $v2w);
         my $path_type = $self->{path_type};
         my $path;
         if ($path_type eq '2/38') {