X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FImport.pm;h=07d1859920003ea820c8ccd70cb536acee9e2f74;hb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;hp=351bc660e19b862424e474de545beba50d26719b;hpb=d55abcc42bde846d9047491125dd2b32645dafd8;p=public-inbox.git diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 351bc660..07d18599 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -15,6 +15,7 @@ use PublicInbox::Address; use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp); use PublicInbox::ContentId qw(content_digest); use PublicInbox::MDA; +use PublicInbox::Eml; use POSIX qw(strftime); sub new { @@ -137,7 +138,7 @@ sub check_remove_v1 { $info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info"; my $oid = $1; my $msg = _cat_blob($r, $w, $oid) or die "BUG: cat-blob $1 failed"; - my $cur = PublicInbox::MIME->new($msg); + my $cur = PublicInbox::Eml->new($msg); my $cur_s = $cur->header('Subject'); $cur_s = '' unless defined $cur_s; my $cur_m = $mime->header('Subject'); @@ -212,13 +213,13 @@ sub get_mark { } # returns undef on non-existent -# ('MISMATCH', Email::MIME) on mismatch -# (:MARK, Email::MIME) on success +# ('MISMATCH', PublicInbox::Eml) on mismatch +# (:MARK, PublicInbox::Eml) on success # # v2 callers should check with Xapian before calling this as # it is not idempotent. sub remove { - my ($self, $mime, $msg) = @_; # mime = Email::MIME + my ($self, $mime, $msg) = @_; # mime = PublicInbox::Eml or Email::MIME my $path_type = $self->{path_type}; my ($path, $err, $cur, $blob); @@ -354,7 +355,7 @@ sub v1_mid0 ($) { my $hdr = $mime->header_obj; my $mids = mids($hdr); - if (!scalar(@$mids)) { # spam often has no Message-Id + if (!scalar(@$mids)) { # spam often has no Message-ID my $mid0 = digest2mid(content_digest($mime), $hdr); append_mid($hdr, $mid0); return $mid0; @@ -374,7 +375,7 @@ sub clean_tree_v2 ($$$) { # returns undef on duplicate # returns the :MARK of the most recent commit sub add { - my ($self, $mime, $check_cb, $smsg) = @_; # mime = Email::MIME + my ($self, $mime, $check_cb, $smsg) = @_; my ($name, $email, $at, $ct, $subject) = extract_cmt_info($mime, $smsg); my $path_type = $self->{path_type}; @@ -440,15 +441,31 @@ sub run_die ($;$$) { $? == 0 or die join(' ', @$cmd) . " failed: $?\n"; } +my @INIT_FILES = ('HEAD' => "ref: refs/heads/master\n", + 'description' => < <{git}->{git_dir} if ref($dir); - my @cmd = (qw(git init --bare -q), $dir); - run_die(\@cmd); - # set a reasonable default: - @cmd = (qw/git config/, "--file=$dir/config", - 'repack.writeBitmaps', 'true'); - run_die(\@cmd); + require File::Path; + File::Path::mkpath([ map { "$dir/$_" } qw(objects/info refs/heads) ]); + for (my $i = 0; $i < @INIT_FILES; $i++) { + my $f = $dir.'/'.$INIT_FILES[$i++]; + next if -f $f; + open my $fh, '>', $f or die "open $f: $!"; + print $fh $INIT_FILES[$i] or die "print $f: $!"; + close $fh or die "close $f: $!"; + } } sub done {