file-digests 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/file-digests.rb +22 -16
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a167cb6f59c4cdae02d1a84636e81a2a2deab97f1f23f6c9a47a3ff875da554
4
- data.tar.gz: 193fb14076bfb7bc66928bbb4d1b6c4ff58c8c9ec9ba3d22bfcbda74960b9416
3
+ metadata.gz: 6028b58b55a01a5075c8ac95b81ef78d53aeddc015990b3823192321515e8cd3
4
+ data.tar.gz: 473996ec0c9bd45b6864da08ac69280a1787536a0405a43ddd1c714fc04f25ae
5
5
  SHA512:
6
- metadata.gz: 20cfd65569fc3919ba8957ced4afca0572044c745a3d31f14f64872ea267599a911bb9e9f2ac203f25d1069c6bc50d4d24600a779d42f49e91a39f701eeaeee6
7
- data.tar.gz: d6cee295615ce3ae115c20fde66533e547148ba7626ebcbc78bf30e6cd5e2d5b3f391ca4068f50e79892ae695636a00c0395f63226a6d9cf5ba4de9d27bcff24
6
+ metadata.gz: 3a7c560a043b17bf63fdcce1a003d9be812ee12f5b46bcfe25a117ab5d250b7b8f8146d89303db2bae9656b351dad6b2c88273198b92555fdef538e987a390e7
7
+ data.tar.gz: 932f4aaeb1fdf886b851880301befa45d7d5f1477d1b36e71807389990bde4b4398961478b7d3c35eaec0346beabf2224a67615be52f724bfa2dc1eb41e74f81
@@ -30,10 +30,8 @@ module FileDigests
30
30
  end
31
31
 
32
32
  def self.perform_check
33
- files_path = Pathname.new patch_path_string(ARGV[0] || ".")
34
- digest_database_path = Pathname.new patch_path_string(ARGV[1]) if ARGV[1]
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
- @counters = {good: 0, updated: 0, new: 0, missing: 0, renamed: 0, likely_damaged: 0, exceptions: 0}
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 digest_database_path
162
- digest_database_path = @files_path + '.file-digests.sqlite'
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 @files_path
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 check
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
- return if filename == '.file-digests.sqlite'
214
- return if filename == '.file-digests.sqlite-wal'
215
- return if filename == '.file-digests.sqlite-shm'
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(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file-digests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav Senotrusov