]> source.dussan.org Git - redmine.git/commitdiff
Fixed Trac importer broken by r2670 (#3254).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 4 May 2009 16:48:27 +0000 (16:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 4 May 2009 16:48:27 +0000 (16:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2705 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/tasks/migrate_from_trac.rake

index 9b245cd1691ad1551eeed8b0416be480f28e4721..a63daae1a9f38b9c44ba1b8d882c6066fef27be7 100644 (file)
@@ -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