]> git.cworth.org Git - sup/commitdiff
fix write_to_disk error in attachment hook handling
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 3 Oct 2007 19:52:07 +0000 (19:52 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 3 Oct 2007 19:52:07 +0000 (19:52 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@599 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/message-chunks.rb

index 276a61d9a225911c70ea9fd571cc410c3a11e4ad..de7d4b5701fb2b958f80d79afcde694d492e76d2 100644 (file)
@@ -77,13 +77,18 @@ EOS
     def expandable?; !viewable? end
     def viewable?; @lines.nil? end
     def view!
+      path = write_to_disk
+      system "/usr/bin/run-mailcap --action=view #{@content_type}:#{path} >& /dev/null"
+      $? == 0
+    end
+
+    def write_to_disk
       file = Tempfile.new "redwood.attachment"
       file.print @raw_content
       file.close
-      system "/usr/bin/run-mailcap --action=view #{@content_type}:#{file.path} >& /dev/null"
-      $? == 0
+      file.path
     end
-    
+
     ## used when viewing the attachment as text
     def to_s
       @lines || @raw_content