]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-mda
mda: support v2 inboxes
[public-inbox.git] / script / public-inbox-mda
index f1eaf629b34012a696eb59ef6af85bc13e6cb7e4..766d58a6f4c22cd97ca91a9fda6dc7bd421d8bca 100755 (executable)
@@ -78,8 +78,18 @@ if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message
 } # else { accept
 
 PublicInbox::MDA->set_list_headers($mime, $dst);
-my $git = PublicInbox::Git->new($main_repo);
-my $im = PublicInbox::Import->new($git, $dst->{name}, $recipient);
+my $v = $dst->{version} || 1;
+my $im;
+if ($v == 2) {
+       require PublicInbox::V2Writable;
+       $im = PublicInbox::V2Writable->new($dst);
+       $im->{parallel} = 0; # pointless to be parallel for a single message
+} elsif ($v == 1) {
+       my $git = $dst->git;
+       $im = PublicInbox::Import->new($git, $dst->{name}, $recipient, $dst);
+} else {
+       die "Unsupported inbox version: $v\n";
+}
 if (defined $im->add($mime)) {
        $emm = $emm->abort;
 } else {