about summary refs log tree commit homepage
path: root/scripts/import_maildir
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/import_maildir')
-rwxr-xr-xscripts/import_maildir27
1 files changed, 17 insertions, 10 deletions
diff --git a/scripts/import_maildir b/scripts/import_maildir
index fbf3f649..7228a3ad 100755
--- a/scripts/import_maildir
+++ b/scripts/import_maildir
@@ -1,22 +1,29 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2014, Eric Wong <e@80x24.org> and all contributors
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-#
-# Script to import a Maildir into a public-inbox
 =begin usage
+Ancient script to import a Maildir into a v1 public-inbox
+
+        # this is only if you want a v1 inbox
         export GIT_DIR=/path/to/your/repo.git
         export GIT_AUTHOR_EMAIL='list@example.com'
         export GIT_AUTHOR_NAME='list name'
         ./import_maildir /path/to/maildir/
+
+For v2 (strongly recommended), use:
+
+        lei convert /path/to/maildir -o /path/to/v2-inbox
+        # (and `lei daemon-kill' if you don't want the daemon to linger)
 =cut
-use strict;
-use warnings;
-use Email::Simple;
+use v5.12;
 use Date::Parse qw/str2time/;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
 use PublicInbox::Git;
 use PublicInbox::Import;
-sub usage { "Usage:\n".join('', grep(/\t/, `head -n 24 $0`)) }
+sub usage {
+        open my $fh, '<', __FILE__;
+        ("Usage:\n", grep { /^=begin usage/../^=cut/ and !/^=/m } <$fh>);
+}
 my $dir = shift @ARGV or die usage();
 my $git_dir = `git rev-parse --git-dir`;
 chomp $git_dir;
@@ -28,7 +35,7 @@ my @msgs;
 foreach my $sub (qw(cur new)) {
         foreach my $fn (glob("$dir/$sub/*")) {
                 open my $fh, '<', $fn or next;
-                my $s = Email::Simple->new(eval { local $/; <$fh> });
+                my $s = PublicInbox::Eml->new(do { local $/; <$fh> });
                 my $date = $s->header('Date');
                 my $t = eval { str2time($date) };
                 defined $t or next;
@@ -45,7 +52,7 @@ my $im = PublicInbox::Import->new($git, $name, $email);
 while (my $ary = pop @msgs) {
         my $fn = "$dir/$ary->[1]";
         open my $fh, '<', $fn or next;
-        my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
+        my $mime = PublicInbox::Eml->new(do { local $/; <$fh> });
         $im->add($mime);
 }
 $im->done;