Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applied patch from Rob Anderton to fix some binmode and open file iss…

…ues that regressed.
  • Loading branch information...
commit 3cc7ab7d079a5091ab1d4cb09973f358a7856e2c 1 parent 9908421
@jyurek jyurek authored
View
3  lib/paperclip/attachment.rb
@@ -67,6 +67,7 @@ def assign uploaded_file
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 @@ def assign uploaded_file
# 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 @@ def self.interpolations
# 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
View
2  lib/paperclip/storage.rb
@@ -38,11 +38,11 @@ def to_file style = default_style
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
View
3  test/iostream_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.