Skip to content

Instantly share code, notes, and snippets.

@astarasikov
Created March 31, 2015 18:59
Show Gist options
  • Save astarasikov/efaabff2112e6a176561 to your computer and use it in GitHub Desktop.
Save astarasikov/efaabff2112e6a176561 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'Digest'
if 2 != ARGV.length then
puts "Usage: $0 dir [good_dir]"
exit -1
end
def probe_file(path, good_path)
return if not File.exists? good_path
md5 = Digest::MD5.file(path).hexdigest
good_md5 = Digest::MD5.file(good_path).hexdigest
if md5 != good_md5 then
puts path
end
end
def scan_dir(top, good)
Dir.foreach(top) do |item|
begin
next if item == '.' or item == '..'
file_path = top + '/' + item
good_path = good + '/' + item
$stderr.puts "AT #{file_path}"
next if (File.size file_path) > (50 << 20)
probe_file(file_path, good_path) if File.file? file_path
scan_dir(file_path, good_path) if File.directory? file_path
rescue
puts "Oops, exception in #{top}/#{item}"
end
end
end
scan_dir(ARGV[0], ARGV[1])
@kavu
Copy link

kavu commented Mar 31, 2015

#5, #14 — Ruby? Не надо then
#22 — лучше || чем or

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment