1 # Copyright (C) 2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # Extends read-only Inbox for writing
5 package PublicInbox::InboxWritable;
8 use base qw(PublicInbox::Inbox);
9 use PublicInbox::Import;
12 my ($class, $ibx) = @_;
17 my ($self, $parallel) = @_;
18 $self->{-importer} ||= eval {
19 my $v = $self->{version} || 1;
21 eval { require PublicInbox::V2Writable };
22 die "v2 not supported: $@\n" if $@;
23 my $v2w = PublicInbox::V2Writable->new($self);
24 $v2w->{parallel} = $parallel;
28 my $name = $self->{name};
29 my $addr = $self->{-primary_address};
30 PublicInbox::Import->new($git, $name, $addr, $self);
32 die "unsupported inbox version: $v\n";
39 my $f = $self->{filter};
40 if ($f && $f =~ /::/) {
41 my @args = (-inbox => $self);
42 # basic line splitting, only
43 # Perhaps we can have proper quote splitting one day...
44 ($f, @args) = split(/\s+/, $f) if $f =~ /\s+/;
50 # e.g: PublicInbox::Filter::Vger->new(@args)
51 return $f->new(@args);