Class: FileDigests::Checker
- Inherits:
-
Object
- Object
- FileDigests::Checker
- Defined in:
- lib/file-digests.rb
Instance Method Summary collapse
-
#initialize(files_path, digest_database_path) ⇒ Checker
constructor
A new instance of Checker.
- #perform_check ⇒ Object
Constructor Details
#initialize(files_path, digest_database_path) ⇒ Checker
Returns a new instance of Checker.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/file-digests.rb', line 133 def initialize files_path, digest_database_path @files_path = cleanup_path(files_path || ".") @prefix_to_remove = @files_path.to_s + '/' raise "Files path must be a readable directory" unless (File.directory?(@files_path) && File.readable?(@files_path)) @digest_database_path = if digest_database_path cleanup_path(digest_database_path) else @files_path + '.file-digests.sqlite' end if File.directory?(@digest_database_path) @digest_database_path = @digest_database_path + '.file-digests.sqlite' end if @files_path == @digest_database_path.dirname @skip_file_digests_sqlite = true end ensure_dir_exists @digest_database_path.dirname if File.exist?(@digest_database_path.dirname + '.file-digests.sha512') @use_sha512 = true end @digest_database = DigestDatabase.new @digest_database_path @counters = {good: 0, updated: 0, new: 0, missing: 0, renamed: 0, likely_damaged: 0, exceptions: 0} end |
Instance Method Details
#perform_check ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/file-digests.rb', line 163 def perform_check measure_time do walk_files do |filename| process_file filename end end @digest_database.process_missing_files @counters if @counters[:likely_damaged] > 0 || @counters[:exceptions] > 0 STDERR.puts "ERRORS WERE OCCURRED" end puts @counters.inspect end |