Commit 09495a11 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 344298: importxml.pl performance problem - Patch by Vance Baarda…

Bug 344298: importxml.pl performance problem - Patch by Vance Baarda <vrb@novell.com> r=ghendricks a=myk
parent 612ed3d7
...@@ -100,11 +100,13 @@ Bugzilla->batch(1); ...@@ -100,11 +100,13 @@ Bugzilla->batch(1);
my $debug = 0; my $debug = 0;
my $mail = ''; my $mail = '';
my $attach_path = '';
my $help = 0; my $help = 0;
my $result = GetOptions( my $result = GetOptions(
"verbose|debug+" => \$debug, "verbose|debug+" => \$debug,
"mail|sendmail!" => \$mail, "mail|sendmail!" => \$mail,
"attach_path=s" => \$attach_path,
"help|?" => \$help "help|?" => \$help
); );
...@@ -365,15 +367,25 @@ sub process_attachment() { ...@@ -365,15 +367,25 @@ sub process_attachment() {
$attachment{'isprivate'} = $attach->{'att'}->{'isprivate'} || 0; $attachment{'isprivate'} = $attach->{'att'}->{'isprivate'} || 0;
$attachment{'filename'} = $attach->field('filename') || "file"; $attachment{'filename'} = $attach->field('filename') || "file";
# Attachment data is not exported in versions 2.20 and older. # Attachment data is not exported in versions 2.20 and older.
if (defined $attach->first_child('data') if (defined $attach->first_child('data') &&
&& defined $attach->first_child('data')->{'att'}->{'encoding'} defined $attach->first_child('data')->{'att'}->{'encoding'}) {
&& $attach->first_child('data')->{'att'}->{'encoding'} =~ /base64/ ) my $encoding = $attach->first_child('data')->{'att'}->{'encoding'};
{ if ($encoding =~ /base64/) {
# decode the base64 # decode the base64
my $data = $attach->field('data'); my $data = $attach->field('data');
my $output = decode_base64($data); my $output = decode_base64($data);
$attachment{'data'} = $output; $attachment{'data'} = $output;
} }
elsif ($encoding =~ /filename/) {
# read the attachment file
Error("attach_path is required", undef) unless ($attach_path);
my $attach_filename = $attach_path . "/" . $attach->field('data');
open(ATTACH_FH, $attach_filename) or
Error("cannot open $attach_filename", undef);
$attachment{'data'} = do { local $/; <ATTACH_FH> };
close ATTACH_FH;
}
}
else { else {
$attachment{'data'} = $attach->field('data'); $attachment{'data'} = $attach->field('data');
} }
...@@ -1212,6 +1224,8 @@ importxml - Import bugzilla bug data from xml. ...@@ -1212,6 +1224,8 @@ importxml - Import bugzilla bug data from xml.
-v --verbose print error and debug information. -v --verbose print error and debug information.
Mulltiple -v increases verbosity Mulltiple -v increases verbosity
-m --sendmail send mail to recipients with log of bugs imported -m --sendmail send mail to recipients with log of bugs imported
--attach_path The path to the attachment files.
(Required if encoding="filename" is used for attachments.)
=head1 OPTIONS =head1 OPTIONS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment