X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FImport.pm;h=60ce7b66419b3ee0e9ad2dca4b93644497539378;hb=23af251dd607c4e75ab1e68063f2c885c48cc035;hp=347382791c3c5bea4401aa8c17262d2296c8ca0d;hpb=47d21e78be57a8f4615be5872e08ec4539423d1f;p=public-inbox.git diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 34738279..60ce7b66 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -25,7 +25,7 @@ sub default_branch () { { GIT_CONFIG => undef }); chomp(my $h = <$r> // ''); close $r; - $h eq '' ? 'refs/heads/master' : $h; + $h eq '' ? 'refs/heads/master' : "refs/heads/$h"; } } @@ -413,19 +413,19 @@ sub add { $smsg->{blob} = $self->get_mark(":$blob"); $smsg->set_bytes($raw_email, $n); if (my $oidx = delete $smsg->{-oidx}) { # used by LeiStore - my @docids = $oidx->blob_exists($smsg->{blob}); - my @vivify_xvmd; - for my $id (@docids) { - if (my $cur = $oidx->get_art($id)) { - # already imported if bytes > 0 - return if $cur->{bytes} > 0; - push @vivify_xvmd, $id; - } else { - warn "W: $smsg->{blob} ", - "#$id gone (bug?)\n"; - } - } - $smsg->{-vivify_xvmd} = \@vivify_xvmd; + my $eidx_git = delete $smsg->{-eidx_git}; + + # we need this sharedkv to dedupe blobs added in the + # same fast-import transaction + my $u = $self->{uniq_skv} //= do { + require PublicInbox::SharedKV; + my $x = PublicInbox::SharedKV->new; + $x->dbh; + $x; + }; + return if !$u->set_maybe($smsg->oidbin, 1); + return if (!$oidx->vivify_xvmd($smsg) && + $eidx_git->check($smsg->{blob})); } } my $ref = $self->{ref}; @@ -451,9 +451,6 @@ sub add { } my @INIT_FILES = ('HEAD' => undef, # filled in at runtime - 'description' => < <clone->b64digest; # Make our own URLs nicer: # See "Base 64 Encoding with URL and Filename Safe Alphabet" in RFC4648 @@ -520,7 +517,7 @@ sub digest2mid ($$) { # Add a date prefix to prevent a leading '-' in case that trips # up some tools (e.g. if a Message-ID were a expected as a # command-line arg) - my $dt = msg_datestamp($hdr); + my $dt = msg_datestamp($hdr, $fallback_time); $dt = POSIX::strftime('%Y%m%d%H%M%S', gmtime($dt)); "$dt.$b64" . '@z'; }