From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6315 166.70.0.0/16 X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 427C11F461; Fri, 17 May 2019 02:01:04 +0000 (UTC) Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hRSBD-0003kG-5H; Thu, 16 May 2019 20:01:03 -0600 Received: from ip72-206-97-68.om.om.cox.net ([72.206.97.68] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1hRSBA-0003Ys-ES; Thu, 16 May 2019 20:01:02 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Eric Wong Cc: Date: Thu, 16 May 2019 21:00:38 -0500 Message-ID: <87h89tzvp5.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1hRSBA-0003Ys-ES;;;mid=<87h89tzvp5.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=72.206.97.68;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/FRBpObxW5MNnDsn46kSEnM+JJf+ZVjo8= X-SA-Exim-Connect-IP: 72.206.97.68 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [PATCH] PublicInbox::Import Extend add with a optional raw message parameter X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) List-Id: I don't trust the MIME type to not munge my email messages in horrible ways upon occasion. Therefore allow for passing in the raw message value instead of trusting the mime object to preserve it. Signed-off-by: "Eric W. Biederman" --- The context here is because the only copy of messages that I save I save in public-inbox I don't want to have to worry about losing information. So I just pass the raw email_str to add. I expect if I were to export these lists public I would want to do some more but for now I am just putting them in public-inbox so that I can read and archive the lists locally. lib/PublicInbox/Import.pm | 10 +++++----- lib/PublicInbox/V2Writable.pm | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 81a38fb6987d..0a63784414f2 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -359,7 +359,7 @@ 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, $email_str) = @_; # mime = Email::MIME my ($name, $email) = extract_author_info($mime); my $hdr = $mime->header_obj; @@ -396,16 +396,16 @@ sub add { } my $blob = $self->{mark}++; - my $str = $mime->as_string; - my $n = length($str); + $email_str ||= $mime->as_string; + my $n = length($email_str); $self->{bytes_added} += $n; print $w "blob\nmark :$blob\ndata ", $n, "\n" or wfail; - print $w $str, "\n" or wfail; + print $w $email_str, "\n" or wfail; # v2: we need this for Xapian if ($self->{want_object_info}) { my $oid = $self->get_mark(":$blob"); - $self->{last_object} = [ $oid, $n, \$str ]; + $self->{last_object} = [ $oid, $n, \$email_str ]; } my $ref = $self->{ref}; my $commit = $self->{mark}++; diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index afcac4d2db86..713d3817cc59 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -109,14 +109,14 @@ sub init_inbox { # returns undef on duplicate or spam # mimics Import::add and wraps it for v2 sub add { - my ($self, $mime, $check_cb) = @_; + my ($self, $mime, $check_cb, $email_str) = @_; $self->{-inbox}->with_umask(sub { - _add($self, $mime, $check_cb) + _add($self, $mime, $check_cb, $email_str) }); } sub _add { - my ($self, $mime, $check_cb) = @_; + my ($self, $mime, $check_cb, $email_str) = @_; # spam check: if ($check_cb) { @@ -135,7 +135,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, $email_str); $cmt = $im->get_mark($cmt); $self->{last_commit}->[$self->{epoch_max}] = $cmt; -- 2.17.1