From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/9] v2writable: preserve timestamps from import
Date: Fri, 20 Mar 2020 08:18:14 +0000 [thread overview]
Message-ID: <20200320081821.21715-3-e@yhbt.net> (raw)
In-Reply-To: <20200320081821.21715-1-e@yhbt.net>
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.
---
lib/PublicInbox/Import.pm | 12 ++++++++----
lib/PublicInbox/V2Writable.pm | 2 +-
2 files changed, 9 insertions(+), 5 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') {
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index f1842843..d39a6f89 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -176,7 +176,7 @@ sub _add {
defined $num or return; # duplicate
defined $mid0 or die "BUG: $mid0 undefined\n";
my $im = $self->importer;
- my $cmt = $im->add($mime);
+ my $cmt = $im->add($mime, undef, $self); # sets $self->{(au|co)time}
$cmt = $im->get_mark($cmt);
$self->{last_commit}->[$self->{epoch_max}] = $cmt;
next prev parent reply other threads:[~2020-03-20 8:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 3:23 [PATCH] index: use git commit times on missing Date/Received Eric Wong
2020-03-05 5:13 ` Eric Wong
2020-03-20 8:18 ` [PATCH 0/9] preserve time and date of initial commit Eric Wong
2020-03-20 8:18 ` [PATCH 1/9] index: use git commit times on missing Date/Received Eric Wong
2020-03-20 8:18 ` Eric Wong [this message]
2020-03-20 8:18 ` [PATCH 3/9] rename PublicInbox::SearchMsg => PublicInbox::Smsg Eric Wong
2020-03-20 8:18 ` [PATCH 4/9] smsg: to_doc_data: use existing fields Eric Wong
2020-03-20 8:18 ` [PATCH 5/9] overidx: parse_references: less error-prone args Eric Wong
2020-03-20 8:18 ` [PATCH 6/9] *idx: pass $smsg in more places instead of many args Eric Wong
2020-03-20 8:18 ` [PATCH 7/9] v2: pass smsg in more places Eric Wong
2020-03-20 8:18 ` [PATCH 8/9] *idx: pass smsg in even " Eric Wong
2020-03-20 8:18 ` [PATCH 9/9] v2: SDBM-based multi Message-ID queue Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200320081821.21715-3-e@yhbt.net \
--to=e@yhbt.net \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).