diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-12-27 17:30:03 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-12-06 11:06:00 +0100 |
commit | 8426dcc12aeea5a86511230de384f57142e76910 (patch) | |
tree | 6a06dfe8bff0bbd1ea55ce81d38a0cba79047882 | |
parent | 1b00de587da2e1baea9b8753c6465c7f529304aa (diff) | |
download | bugzilla-8426dcc12aeea5a86511230de384f57142e76910.tar.gz bugzilla-8426dcc12aeea5a86511230de384f57142e76910.tar.xz |
WIP: misc fixes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | Bugzilla/Migrate.pm | 5 | ||||
-rw-r--r-- | Bugzilla/Migrate/Flyspray.pm | 31 |
2 files changed, 24 insertions, 12 deletions
diff --git a/Bugzilla/Migrate.pm b/Bugzilla/Migrate.pm index f4ae078f9..e52e1ea87 100644 --- a/Bugzilla/Migrate.pm +++ b/Bugzilla/Migrate.pm @@ -716,7 +716,6 @@ sub insert_bugs { my $comments = delete $bug->{comments}; my $history = delete $bug->{history}; my $attachments = delete $bug->{attachments}; - my $dup_id = delete $bug->{dup_id}; $self->debug($bug, 3); @@ -781,10 +780,6 @@ sub insert_bugs { $reporter->{groups} = $super_user->groups; Bugzilla->set_user($reporter); my $created = Bugzilla::Bug->create($bug); - if (defined $dup_id) { - $dbh->do("INSERT INTO duplicates (dupe_of, dupe) VALUES (?, ?)", - undef, $dup_id, $created->id); - } $self->debug('Created bug ' . $created->id); Bugzilla->set_user($super_user); diff --git a/Bugzilla/Migrate/Flyspray.pm b/Bugzilla/Migrate/Flyspray.pm index 9f4c05000..579e7704d 100644 --- a/Bugzilla/Migrate/Flyspray.pm +++ b/Bugzilla/Migrate/Flyspray.pm @@ -417,7 +417,7 @@ sub _read_bugs { "DUPLICATE") { if ($closure_comment =~ m/FS#(\d+)/) { - $bug->{dup_id} = int($1); + $self->{dupes}->{$row->{task_id}} = int($1); } } } @@ -453,20 +453,28 @@ sub _read_bugs { while (my $attachment = $attachments_sth->fetchrow_hashref()) { my $path = $attpath . '/' . $attachment->{file_name}; next unless -f $path; - push @{$bug->{attachments}}, - { + next unless -s $path; + my $attachment_item = { 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($path), - ispatch => $attachment->{file_type} =~ m/^text\/x-diff/ ? 1 : 0, - data_path => $path, - }; + + #mimetype => $attachment->{file_type}, + ispatch => $attachment->{file_type} =~ m/^text\/x-diff/ ? 1 : 0, + data_path => $path, + }; + +#$attachment_item->{mimetype} = mimetype($path) if $attachment_item->{mimetype} eq "" or $attachment_item->{mimetype} !~ m/.+\/.+/; + $attachment_item->{mimetype} = mimetype($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 # change _insert_attachments/_insert_comments? + push @{$bug->{attachments}}, $attachment_item; + + #$self->debug($bug); + #die if $attachment->{date_added} == 1110715864; } push @result, $bug; @@ -527,6 +535,15 @@ sub translate_bug { return wantarray ? ($bug, $other_fields) : $bug; } +sub after_insert { + my ($self) = @_; + + for my $dupe (keys %{$self->{dupes}}) { + $self->{dbh}->do("INSERT INTO duplicates (dupe_of, dupe) VALUES (?, ?)", + undef, $self->{dupes}->{$dupe}, $$dupe); + } +} + # Timestamps from flyspray are unix timestamps which Date::Parse # can't parse so the original parse_date() sub will just die |