Permalink
Browse files

Only checksum the first 256K

  • Loading branch information...
1 parent 78105ee commit b083bee74359b3b07d4caa5be6d10554cbafc74b @paulcbetts committed Nov 23, 2007
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/library.rb
View
5 lib/library.rb
@@ -72,8 +72,9 @@ def load(files, progress_rate = 0.05)
count += 1
#log DEBUG, 'Reading %s..' % current
- # First, see if we've already scanned this file before
- md5sum = Digest::MD5.hexdigest(File.read(current))
+ # First, see if we've already scanned this file before (save some time
+ # and only read the first 256K)
+ md5sum = Digest::MD5.hexdigest(File.open(current, 'r') {|x| x.read(0x80000)})
if (@tag_info[current] = @md5_index[md5sum])
#log DEBUG, "Cache hit!"
next

0 comments on commit b083bee

Please sign in to comment.