Permalink
Browse files

Rewind the file queued for write before returning it

  • Loading branch information...
1 parent b346dd6 commit 32ef45aa4b2f3483160a6bab97e283ac9c5c98ad @exviva committed May 15, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −0 CHANGELOG.md
  2. +6 −1 lib/paperclip/storage/tmp.rb
View
@@ -1,5 +1,6 @@
## Not released yet:
+* Rewind the file queued for write before returning it
* Unlink the file **and** close the file descriptor when clearing
the attachments
@@ -16,7 +16,12 @@ def exists?(style_name = default_style)
end
def to_file(style_name = default_style)
- @queued_for_write[style_name] || (File.new(Tmp.fs[path(style_name)], 'rb') if exists?(style_name))
+ if @queued_for_write[style_name]
+ @queued_for_write[style_name].rewind
+ @queued_for_write[style_name]
+ elsif exists?(style_name)
+ File.new(Tmp.fs[path(style_name)], 'rb')
+ end
end
def flush_writes

0 comments on commit 32ef45a

Please sign in to comment.