sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 17fd0c9bf15e8c114fc05c11a6ba5346154d1730
parent 4101d2af352441d698477398f4fe76ece3906c8b
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Mon, 10 Dec 2007 04:04:42 +0000

be better about USING extensions for attachments

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@761 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M lib/sup/message-chunks.rb | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
@@ -1,3 +1,5 @@
+require 'tmpdir'
+
 ## Here we define all the "chunks" that a message is parsed
 ## into. Chunks are used by ThreadViewMode to render a message. Chunks
 ## are used for both MIME stuff like attachments, for Sup's parsing of
@@ -36,8 +38,7 @@ module Chunk
 Executes when decoding a MIME attachment.
 Variables:
    content_type: the content-type of the message
-       filename: the filename of the attachment as saved to disk (generated
-                 on the fly, so don't call more than once)
+       filename: the filename of the attachment as saved to disk
   sibling_types: if this attachment is part of a multipart MIME attachment,
                  an array of content-types for all attachments. Otherwise,
                  the empty array.
@@ -102,7 +103,13 @@ EOS
     end
 
     def write_to_disk
-      file = Tempfile.new "redwood.attachment"
+      file =
+        if @filename
+          File.open File.join(Dir::tmpdir, @filename), "w"
+        else
+          Tempfile.new "redwood.attachment"
+        end
+
       file.print @raw_content
       file.close
       file.path