From 36d332cb88bc027bb29495f6701d6a97ec4190fc Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 27 Dec 2017 16:50:09 +0100 Subject: WIP: misc fixes Signed-off-by: Florian Pritz --- Bugzilla/Migrate/Flyspray.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Bugzilla/Migrate/Flyspray.pm b/Bugzilla/Migrate/Flyspray.pm index 024b99b4b..cfc605832 100644 --- a/Bugzilla/Migrate/Flyspray.pm +++ b/Bugzilla/Migrate/Flyspray.pm @@ -20,7 +20,9 @@ use Bugzilla::DB; use IO::File; use List::Util qw(first none); use SQL::Abstract; +use File::MimeInfo; +# FIXME: this is currently broken in Bugzilla::Migrate #use constant REQUIRED_MODULES => [ #{ #package => 'SQL-Abstract', @@ -179,7 +181,7 @@ sub _read_users { email => $row->{email_address}, cryptpassword => "*", }; - push @result, $item; + push @result, $item; $self->{map_user_id_to_email}->{$row->{user_id}} = $item->{email}; $self->{map_email_to_name}->{$row->{email_address}} = $item->{login_name}; } @@ -286,10 +288,10 @@ sub _read_bugs { LEFT OUTER JOIN $fsdb.${fsprfx}list_status ls ON ls.status_id = t.item_status LEFT OUTER JOIN $fsdb.${fsprfx}list_resolution lr ON lr.resolution_id = t.resolution_reason LEFT OUTER JOIN $fsdb.${fsprfx}list_version lv ON lv.version_id = t.product_version - WHERE t.task_id IN (21668, 22102, 23845, 23884) GROUP BY t.task_id, a.task_id "); $sth->execute(); + #WHERE t.task_id IN (21668, 22102, 23845, 23884) my @result; while (my $row = $sth->fetchrow_hashref()) { @@ -382,7 +384,7 @@ sub _read_bugs { removed => "", added => $history->{resolution_name}, }; - if ($self->translate_value('resolution', $history->{resolution_name}) eq "DUPLICATE") { + if ($self->translate_value('resolution', $history->{resolution_name} // "") eq "DUPLICATE") { if ($closure_comment =~ m/FS#(\d+)/) { $bug->{dup_id} = int($1); } @@ -413,14 +415,16 @@ sub _read_bugs { $attachments_sth->execute($row->{task_id}); my $attpath = $self->config("attachment_path"); while (my $attachment = $attachments_sth->fetchrow_hashref()) { + my $path = $attpath.'/'.$attachment->{file_name}; + next unless -f $path; push @{$bug->{attachments}}, { submitter => $self->_get_username($attachment->{added_by}), creation_ts => $attachment->{date_added}, description => $attachment->{file_desc} || $attachment->{orig_name}, filename => $attachment->{orig_name}, - mimetype => $attachment->{file_type}, + mimetype => $attachment->{file_type} || mimetype($path), ispatch => $attachment->{file_type} =~ m/^text\/x-diff/ ? 1 : 0, - data => IO::File->new($attpath.'/'.$attachment->{file_name}, 'r'), + data_path => $path, }; # TODO: set extra_data and type of comment when attachment is part of a comment. # problem: how to get attachment id? not yet in db -- cgit v1.2.3-24-g4f1b