Created
March 31, 2015 18:59
-
-
Save astarasikov/efaabff2112e6a176561 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#5, #14 — Ruby? Не надо then
#22 — лучше
||
чемor