diff --git a/bucket-tool b/bucket-tool index a016c10..3eafbc5 100644 --- a/bucket-tool +++ b/bucket-tool @@ -17,7 +17,7 @@ Actions: search : Search for bucket entries matching a portion of the filepath list : List all Bucket entries list-files : List all files/paths that have been backed up to the bucket - get : Get the content of a specific entry (by md5) + get : Get the content of a specific entry (by hash) Global Flags: -d | --debug : Set debug flag @@ -174,14 +174,14 @@ end # BEGIN: Classes class BucketEntry - attr_reader :md5, :filepaths, :mtime + attr_reader :hash, :filepaths, :mtime def initialize (entry_dir) @entry_dir = entry_dir - @md5 = File.basename(entry_dir) + @hash = File.basename(entry_dir) @filepaths = Array.new File.open("#{entry_dir}/paths") do |file| file.read().split(/\n/).each do |path| - log "BucketEntry[#{@md5}] adding #{path} to @filepaths" + log "BucketEntry[#{@hash}] adding #{path} to @filepaths" @filepaths.push(path) end end @@ -190,12 +190,12 @@ class BucketEntry end def path_include? (path_string) - log "BucketEntry[#{md5}] was called with #{path_string}" + log "BucketEntry[#{hash}] was called with #{path_string}" @filepaths.each.any? {|path| path.include? path_string} end def infostring - "Entry [#{@md5}]: + "Entry [#{@hash}]: Paths: #{@filepaths.join(',')} MTIME: #{@mtime} @@ -203,11 +203,11 @@ class BucketEntry end def inline_info - "#{@mtime} : #{@md5} : #{@filepaths.join(',')}" + "#{@mtime} : #{@hash} : #{@filepaths.join(',')}" end def content - log "BucketEntry[#{@md5}] getting contents" + log "BucketEntry[#{@hash}] getting contents" File.open("#{@entry_dir}/contents",'r') do |file| file.read() end @@ -230,7 +230,7 @@ class Bucket log "\"#{directory}\" was grabbed from bucket directory. Making new BucketEntry" entry = BucketEntry.new(directory) @entries.push(entry) - log "BucketEntry[#{entry.md5}] was added to @entries Size=#{@entries.count()}" + log "BucketEntry[#{entry.hash}] was added to @entries Size=#{@entries.count()}" end log "Bucket[#{@bucketdir}] was loaded" end @@ -245,19 +245,19 @@ end def search_entries_paths (bucket) log "user entered" bucket.entries.each do |entry| - log "checking Entry[#{entry.md5}]" + log "checking Entry[#{entry.hash}]" if entry.path_include? $CONFIG[:search_term] puts entry.inline_info end end end -def get_content_of_entry_md5 (bucket) +def get_content_of_entry_hash (bucket) log "user entered" bucket.entries.each do |entry| - log "checking Entry[#{entry.md5}]" - if entry.md5 == $CONFIG[:search_term] - log "BucketEntry[#{entry.md5}] Matched. Getting contents" + log "checking Entry[#{entry.hash}]" + if entry.hash == $CONFIG[:search_term] + log "BucketEntry[#{entry.hash}] Matched. Getting contents" puts entry.content exit end @@ -293,7 +293,7 @@ if __FILE__ == $0 search_entries_paths bucket when 'get' - get_content_of_entry_md5 bucket + get_content_of_entry_hash bucket when 'list' list_all_entries bucket