Commit 3cc7ab7d by Jon Yurek

Applied patch from Rob Anderton to fix some binmode and open file issues that regressed.

parent 9908421d
......@@ -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("paperclip-reprocess")
new_original.binmode
if old_original = to_file(:original)
new_original.write( old_original.read )
new_original.rewind
......
......@@ -38,11 +38,11 @@ module Paperclip
def flush_writes #:nodoc:
logger.info("[paperclip] Writing files for #{name}")
@queued_for_write.each do |style, file|
file.close
FileUtils.mkdir_p(File.dirname(path(style)))
logger.info("[paperclip] -> #{path(style)}")
FileUtils.mv(file.path, path(style))
FileUtils.chmod(0644, path(style))
file.close
end
@queued_for_write = {}
end
......
......@@ -20,7 +20,8 @@ class IOStreamTest < Test::Unit::TestCase
context "and given a String" do
setup do
assert @result = @file.stream_to("/tmp/iostream.string.test")
FileUtils.mkdir_p(File.join(ROOT, 'tmp'))
assert @result = @file.stream_to(File.join(ROOT, 'tmp', 'iostream.string.test'))
end
should "return a File" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment