X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-edit;h=42f914a808d73413f12b7c3499b3b40c862c1f2c;hb=e39585ee2bdcbeaab7b6bd33b3568021042d0879;hp=1900b267fbaed598867dfd66917bad778a0c207f;hpb=fe565af9e3e1634412c21fb2fe2bb7612c430e47;p=public-inbox.git
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index 1900b267..42f914a8 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
-# Copyright (C) 2019 all contributors
+# Copyright (C) 2019-2020 all contributors
# License: AGPL-3.0+
#
# Used for editing messages in a public-inbox.
@@ -8,13 +8,13 @@ use strict;
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::MIME;
+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 };
@@ -22,7 +22,7 @@ my @opt = qw(mid|m=s file|F=s raw);
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';
@@ -92,9 +92,8 @@ Multiple messages with different content found matching
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);