Skip to content
Browse files

Also make sure that file is rewinded in filestore

  • Loading branch information...
1 parent 95d7c4a commit e5ed019196baeee3a7b86c31ddaa0321c07d50e4 @sikachu sikachu committed Jun 15, 2012
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/paperclip/storage/filesystem.rb
  2. +6 −0 test/storage/filesystem_test.rb
View
1 lib/paperclip/storage/filesystem.rb
@@ -36,6 +36,7 @@ def flush_writes #:nodoc:
end
end
FileUtils.chmod(0666&~File.umask, path(style_name))
+ file.rewind
end
after_flush_writes # allows attachment to clean up temp files
View
6 test/storage/filesystem_test.rb
@@ -26,6 +26,12 @@ class FileSystemTest < Test::Unit::TestCase
@dummy.save
assert_file_exists(@dummy.avatar.path(:thumbnail))
end
+
+ should "be rewinded after flush_writes" do
+ files = @dummy.avatar.queued_for_write.map{ |style, file| file }
+ @dummy.save
+ assert files.none?(&:eof?), "Expect all the files to be rewinded."
+ end
end
context "with file that has space in file name" do

1 comment on commit e5ed019

@airblade

Please could you explain why we need to rewind the file?

Please sign in to comment.
Something went wrong with that request. Please try again.