lib/treehash.rb in treehash-0.0.1 vs lib/treehash.rb in treehash-0.0.2
- old
+ new
@@ -17,11 +17,13 @@
shas = []
while mega_byte = handle.read(MEGA_BYTE)
shas << Digest::SHA256.new.digest(mega_byte)
end
+ return nil if shas.empty?
+
while shas.size > 1
- shas = shas.each_slice(2).to_a.map do |pair|
+ shas = shas.each_slice(2).map do |pair|
pair[1] ? Digest::SHA256.new.update(pair[0]).update(pair[1]).digest : pair[0]
end
end
Digest.hexencode shas[0]