}
sub new {
- # $creat may be any true value, or 0/undef. A hashref is true,
- # and $creat->{nproc} may be set to an integer
- my ($class, $v2ibx, $creat) = @_;
- $v2ibx = PublicInbox::InboxWritable->new($v2ibx);
+ my ($class, $v2ibx, $creat_opt) = @_;
+ $v2ibx = PublicInbox::InboxWritable->new($v2ibx, $creat_opt);
my $dir = $v2ibx->assert_usable_dir;
unless (-d $dir) {
- die "$dir does not exist\n" if !$creat;
+ die "$dir does not exist\n" if !$creat_opt;
require File::Path;
File::Path::mkpath($dir);
}
last_commit => [], # git epoch -> commit
};
$self->{oidx}->{-no_fsync} = 1 if $v2ibx->{-no_fsync};
- $self->{shards} = count_shards($self) || nproc_shards($creat);
+ $self->{shards} = count_shards($self) || nproc_shards($creat_opt);
bless $self, $class;
}
foreach my $ibx (@ibxs) {
my $eml = PublicInbox::Eml->new($data);
- my $v2w = PublicInbox::V2Writable->new($ibx, 0);
+ my $v2w = PublicInbox::V2Writable->new($ibx);
my $commits = $v2w->purge($eml) || [];
unless ($dry_run) {
if ($version >= 2) {
require PublicInbox::V2Writable;
- PublicInbox::V2Writable->new($ibx, 1)->init_inbox(0);
+ PublicInbox::V2Writable->new($ibx, {})->init_inbox(0);
} else {
system(qw(git init --bare -q), $inboxdir) == 0 or die;
}
hello world
EOF
-my $im = PublicInbox::V2Writable->new($ibx, 1);
+my $im = PublicInbox::V2Writable->new($ibx, { nproc => 1 });
$im->{parallel} = 0;
ok($im->add($mime), 'message added');
ok($im->remove($mime), 'message removed');
ok($ibx, 'inbox found');
$ibx->{version} = 2;
$ibx->{-no_fsync} = 1;
-my $v2w = PublicInbox::V2Writable->new($ibx, 1);
+my $v2w = PublicInbox::V2Writable->new($ibx, { nproc => 1 });
ok $v2w, 'v2w loaded';
$v2w->{parallel} = 0;
my $mime = PublicInbox::Eml->new(<<'');
{
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
- my $im = PublicInbox::V2Writable->new($ibx, 1);
+ my $im = PublicInbox::V2Writable->new($ibx);
eval { $im->index_sync({reindex => 1}) };
is($@, '', 'no error from reindexing');
$im->done;
{
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
- my $im = PublicInbox::V2Writable->new($ibx, 1);
+ my $im = PublicInbox::V2Writable->new($ibx);
eval { $im->index_sync({reindex => 1}) };
is($@, '', 'no error from reindexing');
$im->done;
local $SIG{__WARN__} = sub { push @warn, @_ };
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
- my $im = PublicInbox::V2Writable->new($ibx, 1);
+ my $im = PublicInbox::V2Writable->new($ibx);
eval { $im->index_sync({reindex => 1}) };
is($@, '', 'no error from reindexing without msgmap');
is(scalar(@warn), 0, 'no warnings from reindexing');
local $SIG{__WARN__} = sub { push @warn, @_ };
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
- my $im = PublicInbox::V2Writable->new($ibx, 1);
+ my $im = PublicInbox::V2Writable->new($ibx);
eval { $im->index_sync({reindex => 1}) };
is($@, '', 'no error from reindexing without msgmap');
is_deeply(\@warn, [], 'no warnings');
ok($@, 'V2Writable fails on non-existent dir');
{
- my $v2w = PublicInbox::V2Writable->new($tmp, 1);
+ my $v2w = PublicInbox::V2Writable->new($tmp, { nproc => 1 });
ok($v2w, 'creat flag works');
$v2w->{parallel} = 0;
$v2w->init_inbox(0);