Created
December 9, 2010 22:54
-
-
Save flazz/735465 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'digest/sha1' | |
| def buf_sha file, buf_size | |
| d = Digest::SHA1.new | |
| buf = String.new | |
| open(file) do |io| | |
| d.update buf while io.read(buf_size, buf) | |
| end | |
| d | |
| end | |
| file = 'data' | |
| MiB = 1024 ** 2 | |
| # uncomment the line below to generate the data file | |
| # `dd if=/dev/urandom of=#{file} bs=#{MiB} count=550` | |
| puts "Digest::SHA1#file:\t#{Digest::SHA1.file(file)}" | |
| buf_size = 512 * MiB | |
| puts "updated < 512 MiB:\t#{buf_sha(file, buf_size - 1)}" | |
| puts "updated = 512 MiB:\t#{buf_sha(file, buf_size)}" | |
| puts "updated = file size:\t#{buf_sha(file, File.size(file))}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At any rate I've got a merge request for your bagit library which I think addresses large file support.