lib/carrierwave/sanitized_file.rb in carrierwave-0.8.0 vs lib/carrierwave/sanitized_file.rb in carrierwave-0.9.0
- old
+ new
@@ -28,11 +28,11 @@
def initialize(file)
self.file = file
end
##
- # Returns the filename as is, without sanizting it.
+ # Returns the filename as is, without sanitizing it.
#
# === Returns
#
# [String] the unsanitized filename
#
@@ -151,14 +151,18 @@
# === Returns
#
# [String] contents of the file
#
def read
- if is_path?
+ if @content
+ @content
+ elsif is_path?
File.open(@file, "rb") {|file| file.read}
else
@file.rewind if @file.respond_to?(:rewind)
- @file.read
+ @content = @file.read
+ @file.close if @file.respond_to?(:close) && @file.respond_to?(:closed?) && !@file.closed?
+ @content
end
end
##
# Moves the file to the given path