Created
August 16, 2011 15:13
-
-
Save fguillen/1149333 to your computer and use it in GitHub Desktop.
Dropbox: calculate a directory hash that includes every recursive subfolder
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
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