diff options
author | lpsolit%gmail.com <> | 2006-07-14 04:04:06 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2006-07-14 04:04:06 +0200 |
commit | 09495a118b165d60d17780a8623318c19d6ffae6 (patch) | |
tree | b0925b111d3f3e2cc8fd4ac3434fa6d6fc602e26 | |
parent | 612ed3d7d8e19de6974bcf26b2a7341c17e6ae52 (diff) | |
download | bugzilla-09495a118b165d60d17780a8623318c19d6ffae6.tar.gz bugzilla-09495a118b165d60d17780a8623318c19d6ffae6.tar.xz |
Bug 344298: importxml.pl performance problem - Patch by Vance Baarda <vrb@novell.com> r=ghendricks a=myk
-rwxr-xr-x | importxml.pl | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/importxml.pl b/importxml.pl index 6ed2727ea..dbcc72f1c 100755 --- a/importxml.pl +++ b/importxml.pl @@ -100,11 +100,13 @@ Bugzilla->batch(1); my $debug = 0; my $mail = ''; +my $attach_path = ''; my $help = 0; my $result = GetOptions( "verbose|debug+" => \$debug, "mail|sendmail!" => \$mail, + "attach_path=s" => \$attach_path, "help|?" => \$help ); @@ -365,14 +367,24 @@ sub process_attachment() { $attachment{'isprivate'} = $attach->{'att'}->{'isprivate'} || 0; $attachment{'filename'} = $attach->field('filename') || "file"; # Attachment data is not exported in versions 2.20 and older. - if (defined $attach->first_child('data') - && defined $attach->first_child('data')->{'att'}->{'encoding'} - && $attach->first_child('data')->{'att'}->{'encoding'} =~ /base64/ ) - { - # decode the base64 - my $data = $attach->field('data'); - my $output = decode_base64($data); - $attachment{'data'} = $output; + if (defined $attach->first_child('data') && + defined $attach->first_child('data')->{'att'}->{'encoding'}) { + my $encoding = $attach->first_child('data')->{'att'}->{'encoding'}; + if ($encoding =~ /base64/) { + # decode the base64 + my $data = $attach->field('data'); + my $output = decode_base64($data); + $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 { $attachment{'data'} = $attach->field('data'); @@ -1212,6 +1224,8 @@ importxml - Import bugzilla bug data from xml. -v --verbose print error and debug information. Mulltiple -v increases verbosity -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 |