]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
import: force Message-ID generation for v1 here
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 656f0693a261f7dd92800557fd2f9c1ae30e2409..a305842e311c7e1772d7856f0bd6efd2c842619f 100644 (file)
@@ -146,19 +146,19 @@ sub num_for_harder {
 
        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);
                }
@@ -220,6 +220,7 @@ sub remove {
                                warn "broken smsg for $mid\n";
                                return 1; # continue
                        }
+                       my $orig = $$msg;
                        my $cur = PublicInbox::MIME->new($msg);
                        if (content_id($cur) eq $cid) {
                                $mm->num_delete($smsg->num);
@@ -227,7 +228,8 @@ sub remove {
                                # no bugs in our deduplication code:
                                $removed = $smsg;
                                $removed->{mime} = $cur;
-                               $im->remove($cur, $cmt_msg);
+                               $im->remove(\$orig, $cmt_msg);
+                               $orig = undef;
                                $removed->num; # memoize this for callers
 
                                my $oid = $smsg->{blob};
@@ -261,13 +263,8 @@ sub checkpoint {
 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};