Skip to content

Commit 92138c4

Browse files
committed
Use buffered read while generating checksum for blob
1 parent b1d57fb commit 92138c4

File tree

1 file changed

+3
-2
lines changed
  • activestorage/app/models/active_storage

1 file changed

+3
-2
lines changed

activestorage/app/models/active_storage/blob.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ def compute_checksum_in_chunks(io)
350350
raise ArgumentError, "io must be rewindable" unless io.respond_to?(:rewind)
351351

352352
OpenSSL::Digest::MD5.new.tap do |checksum|
353-
while chunk = io.read(5.megabytes)
354-
checksum << chunk
353+
read_buffer = "".b
354+
while io.read(5.megabytes, read_buffer)
355+
checksum << read_buffer
355356
end
356357

357358
io.rewind

0 commit comments

Comments
 (0)