Module: SmartS3Sync::DigestCache
- Defined in:
- lib/smart_s3_sync/digest_cache.rb
Class Method Summary collapse
Class Method Details
.digest(filename) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/smart_s3_sync/digest_cache.rb', line 7 def digest(filename) if (cr = cache_record(filename)) && File.mtime(filename).to_i <= cr[0] cr[1] else Digest::MD5.file(filename).hexdigest.tap do |digest| save_record(filename, File.mtime(filename).to_i, digest) end end end |
.save_record(filename, mtime, digest) ⇒ Object
17 18 19 |
# File 'lib/smart_s3_sync/digest_cache.rb', line 17 def save_record(filename, mtime, digest) database.execute("INSERT OR REPLACE INTO files (filename, mtime, digest) VALUES (?, ?, ?)", [filename, mtime, digest]) end |