X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FImport.pm;h=8c9d1cbad526a7d1e5dd3813f390685a0cd3713b;hb=7174681c0165008ac16ed1d323f6d95b6d0570a3;hp=1ac112b8a44222fa830f9635242155ffd00084de;hpb=8f8a070ab8863e0a6726a1d04815b96a0ee432b3;p=public-inbox.git diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 1ac112b8..8c9d1cba 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -54,6 +54,8 @@ sub gfi_start { $self->{lockfh} = $lockfh; $self->{pid} = $pid; $self->{nchg} = 0; + binmode $out_w, ':raw' or die "binmode :raw failed: $!"; + binmode $in_r, ':raw' or die "binmode :raw failed: $!"; ($in_r, $out_w); } @@ -88,7 +90,7 @@ sub _check_path ($$$$) { # ('MISMATCH', msg) on mismatch # (:MARK, msg) on success sub remove { - my ($self, $mime) = @_; # mime = Email::MIME + my ($self, $mime, $msg) = @_; # mime = Email::MIME my $mid = mid_mime($mime); my $path = mid2path($mid); @@ -119,7 +121,7 @@ sub remove { $n = read($r, my $lf, 1); defined($n) or die "read final byte of cat-blob failed: $!"; die "bad read on final byte: <$lf>" if $lf ne "\n"; - my $cur = Email::MIME->new($buf); + my $cur = PublicInbox::MIME->new($buf); my $cur_s = $cur->header('Subject'); $cur_s = '' unless defined $cur_s; my $cur_m = $mime->header('Subject'); @@ -136,10 +138,12 @@ sub remove { } my $ident = $self->{ident}; my $now = now2822(); + $msg ||= 'rm'; + my $len = length($msg) + 1; print $w "commit $ref\nmark :$commit\n", "author $ident $now\n", "committer $ident $now\n", - "data 3\nrm\n\n", + "data $len\n$msg\n\n", 'from ', ($parent ? $parent : $tip), "\n" or wfail; print $w "D $path\n\n" or wfail; $self->{nchg}++; @@ -187,15 +191,15 @@ sub add { print $w "reset $ref\n" or wfail; } + utf8::encode($email); + utf8::encode($name); + utf8::encode($subject); # quiet down wide character warnings: - binmode $w, ':utf8' or die "binmode :utf8 failed: $!"; print $w "commit $ref\nmark :$commit\n", "author $name <$email> $date\n", - "committer $self->{ident} ", now2822(), "\n", - "data ", (bytes::length($subject) + 1), "\n", + "committer $self->{ident} ", now2822(), "\n" or wfail; + print $w "data ", (length($subject) + 1), "\n", $subject, "\n\n" or wfail; - binmode $w, ':raw' or die "binmode :raw failed: $!"; - if ($tip ne '') { print $w 'from ', ($parent ? $parent : $tip), "\n" or wfail; }