#!/usr/bin/perl -w
-# Copyright (C) 2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Used for editing messages in a public-inbox.
use warnings;
use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
use PublicInbox::AdminEdit;
-use File::Temp ();
+use File::Temp 0.19 (); # 0.19 for TMPDIR
use PublicInbox::ContentId qw(content_id);
use PublicInbox::MID qw(mid_clean mids);
PublicInbox::Admin::check_require('-index');
-require PublicInbox::MIME;
-require PublicInbox::InboxWritable;
-require PublicInbox::Import;
+use PublicInbox::Eml;
+use PublicInbox::InboxWritable;
+use PublicInbox::Import;
my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, raw => 0 };
GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or
die "bad command-line args\n$usage\n";
-my $cfg = eval { PublicInbox::Config->new };
+my $cfg = PublicInbox::Config->new;
my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
unless (defined $editor) {
my $k = 'publicinbox.mailEditor';
my ($id, $prev);
while (my $smsg = $over->next_by_mid($mid, \$id, \$prev)) {
my $ref = $ibx->msg_by_smsg($smsg);
- my $mime = PublicInbox::MIME->new($ref);
+ my $mime = PublicInbox::Eml->new($ref);
my $cid = content_id($mime);
my $tuple = [ $ibx, $smsg ];
push @{$found->{$cid} ||= []}, $tuple
warn "Will edit all of them\n";
}
} else {
- open my $fh, '<', $file or die "open($file) failed: $!";
- my $orig = do { local $/; <$fh> };
- my $mime = PublicInbox::MIME->new(\$orig);
+ my $mime = PublicInbox::InboxWritable::mime_from_path($file) or
+ die "open($file) failed: $!";
my $mids = mids($mime->header_obj);
find_mid($found, $_, \@ibxs) for (@$mids); # populates $found
my $cid = content_id($mime);
$new_raw =~ s/^>(>*From )/$1/gm;
}
- my $new_mime = PublicInbox::MIME->new(\$new_raw);
- my $old_mime = PublicInbox::MIME->new($old_raw);
+ my $new_mime = PublicInbox::Eml->new(\$new_raw);
+ my $old_mime = PublicInbox::Eml->new($old_raw);
# make sure we don't compare unwanted headers, since mutt adds
# Content-Length, Status, and Lines headers: