<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -67,6 +67,7 @@ module Paperclip
 
       if uploaded_file.is_a?(Paperclip::Attachment)
         uploaded_file = uploaded_file.to_file(:original)
+        close_uploaded_file = uploaded_file.respond_to?(:close)
       end
 
       return nil unless valid_assignment?(uploaded_file)
@@ -93,6 +94,7 @@ module Paperclip
       # Reset the file size if the original file was reprocessed.
       instance_write(:file_size, uploaded_file.size.to_i)
     ensure
+      uploaded_file.close if close_uploaded_file
       validate
     end
 
@@ -212,6 +214,7 @@ module Paperclip
     # the post-process again.
     def reprocess!
       new_original = Tempfile.new(&quot;paperclip-reprocess&quot;)
+      new_original.binmode
       if old_original = to_file(:original)
         new_original.write( old_original.read )
         new_original.rewind</diff>
      <filename>lib/paperclip/attachment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,11 +38,11 @@ module Paperclip
       def flush_writes #:nodoc:
         logger.info(&quot;[paperclip] Writing files for #{name}&quot;)
         @queued_for_write.each do |style, file|
+          file.close
           FileUtils.mkdir_p(File.dirname(path(style)))
           logger.info(&quot;[paperclip] -&gt; #{path(style)}&quot;)
           FileUtils.mv(file.path, path(style))
           FileUtils.chmod(0644, path(style))
-          file.close
         end
         @queued_for_write = {}
       end</diff>
      <filename>lib/paperclip/storage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,8 @@ class IOStreamTest &lt; Test::Unit::TestCase
 
       context &quot;and given a String&quot; do
         setup do
-          assert @result = @file.stream_to(&quot;/tmp/iostream.string.test&quot;)
+          FileUtils.mkdir_p(File.join(ROOT, 'tmp'))
+          assert @result = @file.stream_to(File.join(ROOT, 'tmp', 'iostream.string.test'))
         end
 
         should &quot;return a File&quot; do</diff>
      <filename>test/iostream_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9908421dc4f69e06b39ed18dde6409fd596f2b34</id>
    </parent>
  </parents>
  <author>
    <name>Jon Yurek</name>
    <email>jyurek@thoughtbot.com</email>
  </author>
  <url>http://github.com/thoughtbot/paperclip/commit/3cc7ab7d079a5091ab1d4cb09973f358a7856e2c</url>
  <id>3cc7ab7d079a5091ab1d4cb09973f358a7856e2c</id>
  <committed-date>2008-12-30T09:01:16-08:00</committed-date>
  <authored-date>2008-12-30T09:01:16-08:00</authored-date>
  <message>Applied patch from Rob Anderton to fix some binmode and open file issues that regressed.</message>
  <tree>38d2705336af22709f02d3d26a8137b956f8b020</tree>
  <committer>
    <name>Jon Yurek</name>
    <email>jyurek@thoughtbot.com</email>
  </committer>
</commit>
