X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-edit;h=e895a228386e9f58cbeff6b42dba4daa4d877d71;hb=46742d95647c7a80cb2f60d5c134717dd91e22e2;hp=1900b267fbaed598867dfd66917bad778a0c207f;hpb=fe565af9e3e1634412c21fb2fe2bb7612c430e47;p=public-inbox.git diff --git a/script/public-inbox-edit b/script/public-inbox-edit index 1900b267..e895a228 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::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 }; @@ -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'; @@ -52,7 +52,7 @@ sub find_mid ($$$) { 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 @@ -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); @@ -206,8 +205,8 @@ W: possible message boundary splitting error $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: