sub new {
my ($class, $v2ibx, $creat) = @_;
my $dir = $v2ibx->{mainrepo} or die "no mainrepo in inbox\n";
+ my $lock_path = "$dir/inbox.lock";
unless (-d $dir) {
if ($creat) {
require File::Path;
File::Path::mkpath($dir);
+ open my $fh, '>>', $lock_path or
+ die "failed to open $lock_path: $!\n";
} else {
die "$dir does not exist\n";
}
xap_ro => undef,
partitions => $nparts,
transact_bytes => 0,
+ lock_path => "$dir/inbox.lock",
# limit each repo to 1GB or so
rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR),
};
my $hdr = $mime->header_obj;
my $dig = content_digest($mime);
- $$mid0 = $dig->clone->hexdigest . '@localhost';
+ $$mid0 = PublicInbox::Import::digest2mid($dig);
my $num = $self->{skel}->{mm}->mid_insert($$mid0);
unless (defined $num) {
# it's hard to spoof the last Received: header
my @recvd = $hdr->header_raw('Received');
$dig->add("Received: $_") foreach (@recvd);
- $$mid0 = $dig->clone->hexdigest . '@localhost';
+ $$mid0 = PublicInbox::Import::digest2mid($dig);
$num = $self->{skel}->{mm}->mid_insert($$mid0);
# fall back to a random Message-ID and give up determinism:
until (defined($num)) {
$dig->add(rand);
- $$mid0 = $dig->clone->hexdigest . '@localhost';
+ $$mid0 = PublicInbox::Import::digest2mid($dig);
warn "using random Message-ID <$$mid0> as fallback\n";
$num = $self->{skel}->{mm}->mid_insert($$mid0);
}
sub barrier {
my ($self) = @_;
- # For safety, we ensure git checkpoint is complete before because
- # the data in git is still more important than what is in Xapian.
- # Performance may be gained by delaying ->progress call but we
- # lose safety
if (my $im = $self->{im}) {
- $im->checkpoint;
- $im->progress('checkpoint');
+ $im->barrier;
}
my $skel = $self->{skel};
my $parts = $self->{idx_parts};
my $im = PublicInbox::Import->new($git, undef, undef, $self->{-inbox});
$im->{bytes_added} = int($packed_bytes / $PACKING_FACTOR);
$im->{want_object_info} = 1;
- $im->{ssoma_lock} = 0;
+ $im->{lock_path} = $self->{lock_path};
$im->{path_type} = 'v2';
$self->{im} = $im;
}