Skip to content

Instantly share code, notes, and snippets.

@fguillen
Created August 16, 2011 15:13
Show Gist options
  • Save fguillen/1149333 to your computer and use it in GitHub Desktop.
Save fguillen/1149333 to your computer and use it in GitHub Desktop.
Dropbox: calculate a directory hash that includes every recursive subfolder
module Dropbox
class Entry
def recursive_hash
return metadata.hash unless metadata.is_dir
recursive_hashes =
list.select{ |e| e.is_dir }.map do |e|
@session.entry( e.path ).recursive_hash
end
recursive_hashes << metadata.hash
recursive_hashes.sort!
Digest::MD5.hexdigest( recursive_hashes.join )
end
end
end
# session.entry( '/my_dir' ).recursive_path # => "742dcd2b0ea021eaa36d35fd92ddecea"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment