From ace65df230f4c49411cfca980c4f3683433f8045 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 4 May 2009 16:50:03 +0000 Subject: [PATCH] Merged r2705 from trunk (#3291). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.8-stable@2706 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/tasks/migrate_from_trac.rake | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake index 02d921300..ce54359ad 100644 --- a/lib/tasks/migrate_from_trac.rake +++ b/lib/tasks/migrate_from_trac.rake @@ -135,8 +135,15 @@ namespace :redmine do File.file? trac_fullpath end - def read - File.open("#{trac_fullpath}", 'rb').read + def open + File.open("#{trac_fullpath}", 'rb') {|f| + @file = f + yield self + } + end + + def read(*args) + @file.read(*args) end def description @@ -506,12 +513,14 @@ namespace :redmine do # Attachments ticket.attachments.each do |attachment| next unless attachment.exist? - a = Attachment.new :created_on => attachment.time - a.file = attachment - a.author = find_or_create_user(attachment.author) - a.container = i - a.description = attachment.description - migrated_ticket_attachments += 1 if a.save + attachment.open { + a = Attachment.new :created_on => attachment.time + a.file = attachment + a.author = find_or_create_user(attachment.author) + a.container = i + a.description = attachment.description + migrated_ticket_attachments += 1 if a.save + } end # Custom fields -- 2.39.5