]> Sergey Matveev's repositories - public-inbox.git/blobdiff - scripts/import_slrnspool
scripts/import_slrnspool: cleanup progress messages
[public-inbox.git] / scripts / import_slrnspool
index 5158460bfa1bfdba325a90c28dd1dfd2e654e92c..1a7d77a4d767d5d69f5e9a1b341dffa2841e7e56 100755 (executable)
@@ -11,7 +11,7 @@
 use strict;
 use warnings;
 use PublicInbox::Config;
-use Email::MIME;
+use PublicInbox::MIME;
 use PublicInbox::Import;
 use PublicInbox::Git;
 sub usage { "Usage:\n".join('',grep(/\t/, `head -n 10 $0`)) }
@@ -25,7 +25,15 @@ defined $recipient or die usage();
 my $config = PublicInbox::Config->new;
 my $ibx = $config->lookup($recipient);
 my $git = $ibx->git;
-my $im = PublicInbox::Import->new($git, $ibx->{name}, $ibx->{-primary_address});
+my $im;
+if (($ibx->{version} || 1) == 2) {
+       require PublicInbox::V2Writable;
+       $im = PublicInbox::V2Writable->new($ibx);
+       $im->{parallel} = 0; # pointless to be parallel for a single message
+} else {
+       $im = PublicInbox::Import->new($git, $ibx->{name},
+                                       $ibx->{-primary_address});
+}
 
 sub key {
        "publicinbox.$ibx->{name}.importslrnspoolstate";
@@ -51,14 +59,15 @@ my $n = get_min();
 my $ok;
 my $max_gap = 200000;
 my $max = $n + $max_gap;
+$spool =~ s!/+\z!!;
 
 for (; $exit == 0 && $n < $max; $n++) {
        my $fn = "$spool/$n";
-       print STDERR $fn, "\n";
        open(my $fh, '<', $fn) or next;
        $max = $n + $max_gap;
+       print STDERR $fn, "\n";
 
-       my $mime = Email::MIME->new(eval { local $/; <$fh> });
+       my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
        my $hdr = $mime->header_obj;
 
        # gmane rewrites Received headers, which increases spamminess