file-digests 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/file-digests.rb +22 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6028b58b55a01a5075c8ac95b81ef78d53aeddc015990b3823192321515e8cd3
|
4
|
+
data.tar.gz: 473996ec0c9bd45b6864da08ac69280a1787536a0405a43ddd1c714fc04f25ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a7c560a043b17bf63fdcce1a003d9be812ee12f5b46bcfe25a117ab5d250b7b8f8146d89303db2bae9656b351dad6b2c88273198b92555fdef538e987a390e7
|
7
|
+
data.tar.gz: 932f4aaeb1fdf886b851880301befa45d7d5f1477d1b36e71807389990bde4b4398961478b7d3c35eaec0346beabf2224a67615be52f724bfa2dc1eb41e74f81
|
data/lib/file-digests.rb
CHANGED
@@ -30,10 +30,8 @@ module FileDigests
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.perform_check
|
33
|
-
|
34
|
-
|
35
|
-
checker = Checker.new files_path, digest_database_path
|
36
|
-
checker.check
|
33
|
+
checker = Checker.new ARGV[0], ARGV[1]
|
34
|
+
checker.perform_check
|
37
35
|
end
|
38
36
|
|
39
37
|
class DigestDatabase
|
@@ -154,26 +152,32 @@ module FileDigests
|
|
154
152
|
|
155
153
|
class Checker
|
156
154
|
def initialize files_path, digest_database_path
|
157
|
-
@
|
158
|
-
@files_path = files_path
|
155
|
+
@files_path = Pathname.new(FileDigests::patch_path_string(files_path || ".")).cleanpath
|
159
156
|
@prefix_to_remove = @files_path.to_s + '/'
|
160
157
|
|
161
|
-
unless
|
162
|
-
|
158
|
+
raise "Files path must be a readable directory" unless (File.directory?(@files_path) && File.readable?(@files_path))
|
159
|
+
|
160
|
+
@digest_database_path = if digest_database_path
|
161
|
+
Pathname.new(FileDigests::patch_path_string(digest_database_path)).cleanpath
|
162
|
+
else
|
163
|
+
@files_path + '.file-digests.sqlite'
|
164
|
+
end
|
165
|
+
|
166
|
+
if @files_path == @digest_database_path.dirname
|
163
167
|
@skip_file_digests_sqlite = true
|
164
168
|
end
|
165
169
|
|
166
|
-
FileDigests::ensure_dir_exists @
|
167
|
-
FileDigests::ensure_dir_exists digest_database_path.dirname
|
170
|
+
FileDigests::ensure_dir_exists @digest_database_path.dirname
|
168
171
|
|
169
|
-
if File.exist?(digest_database_path.dirname + '.file-digests.sha512')
|
172
|
+
if File.exist?(@digest_database_path.dirname + '.file-digests.sha512')
|
170
173
|
@use_sha512 = true
|
171
174
|
end
|
172
175
|
|
173
|
-
@digest_database = DigestDatabase.new digest_database_path
|
176
|
+
@digest_database = DigestDatabase.new @digest_database_path
|
177
|
+
@counters = {good: 0, updated: 0, new: 0, missing: 0, renamed: 0, likely_damaged: 0, exceptions: 0}
|
174
178
|
end
|
175
179
|
|
176
|
-
def
|
180
|
+
def perform_check
|
177
181
|
FileDigests::measure_time do
|
178
182
|
walk_files do |filename|
|
179
183
|
process_file filename
|
@@ -210,9 +214,11 @@ module FileDigests
|
|
210
214
|
return if stat.socket?
|
211
215
|
|
212
216
|
if @skip_file_digests_sqlite
|
213
|
-
|
214
|
-
return if
|
215
|
-
return if
|
217
|
+
basename = File.basename(filename)
|
218
|
+
return if basename == '.file-digests.sha512'
|
219
|
+
return if basename == '.file-digests.sqlite'
|
220
|
+
return if basename == '.file-digests.sqlite-wal'
|
221
|
+
return if basename == '.file-digests.sqlite-shm'
|
216
222
|
end
|
217
223
|
|
218
224
|
@digest_database.insert_or_update(
|