file-digests 0.0.28 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/file-digests.rb +32 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 406b02c22923ae98c45dc92f2836a99dffa6dc8b2343ff62b5b5957a4a154bdc
4
- data.tar.gz: 5898cbc3826818da8c3fa5cf16a334bcb4627f95dc2635a297cc9c7d81d25dfe
3
+ metadata.gz: 68dea8d33894b138d5908dcf27fef7800a17af8f1441fd043876248414ad9525
4
+ data.tar.gz: da5c89c26fc95ddeaa6b8443193293490e71f41bc4ed21e00415c5937661833e
5
5
  SHA512:
6
- metadata.gz: '021494ba0a65daada30e55c63e489c60c018ae3b189409be200635948132f0ed5118d217388e81d8097bc991cf10fea2ce09c4a3a7c148c1fdaa8f66e6b8e074'
7
- data.tar.gz: 3a28808aa979157a2597b5ea56ad006576d28f35678cbaa6e13d62be20aa37066a9d4684d48f5ed2990b24c42acb2ee8cd2d0f14f4f9b12f893c5b3946d5b76e
6
+ metadata.gz: 05e700dedeebde8e472e8adf6b0eedb6c3692b919b3d478a041c8e8110375daae7dd926cd9c33c46379976730f0fb0610880a57524aa44e0764fa169a4020fad
7
+ data.tar.gz: c0e954b6250223e53ec0823f328bd808886f9566ecf373ceaaba5da7a079ae76e18dfba3cf81bfad0741ea8dfdb87c1715c81f8af72094b77abe014fc59727ef
@@ -75,7 +75,12 @@ class FileDigests
75
75
  options[:quiet] = true
76
76
  end
77
77
 
78
- opts.on("-t", "--test", "Perform only the test, do not modify the digest database.") do
78
+ opts.on(
79
+ "-t", "--test",
80
+ "Perform a test to verify directory contents.",
81
+ "Compare actual files with the stored digests, check if any files are missing.",
82
+ "Digest database will not be modified."
83
+ ) do
79
84
  options[:test_only] = true
80
85
  end
81
86
 
@@ -124,7 +129,9 @@ class FileDigests
124
129
 
125
130
  @digest_database_path = digest_database_path ? cleanup_path(digest_database_path) : @files_path
126
131
  @digest_database_path += ".file-digests.sqlite" if File.directory?(@digest_database_path)
127
- ensure_dir_exists @digest_database_path.dirname
132
+ ensure_dir_exist @digest_database_path.dirname
133
+
134
+ @digest_database_files = ["#{@digest_database_path}", "#{@digest_database_path}-wal", "#{@digest_database_path}-shm"]
128
135
 
129
136
  if @options[:verbose]
130
137
  puts "Target directory: #{@files_path}"
@@ -227,6 +234,7 @@ class FileDigests
227
234
  end
228
235
 
229
236
  nested_transaction do
237
+ puts "Tracking renames..." if @options[:verbose]
230
238
  track_renames
231
239
  end
232
240
 
@@ -237,6 +245,7 @@ class FileDigests
237
245
  print_missing_files
238
246
  if !@options[:test_only] && (@options[:auto] || confirm("Remove missing files from the database"))
239
247
  nested_transaction do
248
+ puts "Removing missing files..." if @options[:verbose]
240
249
  remove_missing_files
241
250
  end
242
251
  end
@@ -247,6 +256,7 @@ class FileDigests
247
256
  if any_missing_files? || any_likely_damaged? || any_exceptions?
248
257
  STDERR.puts "ERROR: New digest algorithm will not be in effect until there are files that are missing, likely damaged, or processed with an exception."
249
258
  else
259
+ puts "Updating database to a new digest algorithm..." if @options[:verbose]
250
260
  @new_digests.each do |old_digest, new_digest|
251
261
  update_digest_to_new_digest new_digest, old_digest
252
262
  end
@@ -261,12 +271,15 @@ class FileDigests
261
271
 
262
272
  set_metadata(@options[:test_only] ? "latest_test_only_check_time" : "latest_complete_check_time", time_to_database(Time.now))
263
273
 
264
- execute "PRAGMA optimize"
265
- execute "VACUUM"
266
- execute "PRAGMA wal_checkpoint(TRUNCATE)"
267
-
268
274
  print_counters
269
275
  end
276
+
277
+ puts "Performing database maintenance..." if @options[:verbose]
278
+ execute "PRAGMA optimize"
279
+ execute "VACUUM"
280
+ execute "PRAGMA wal_checkpoint(TRUNCATE)"
281
+
282
+ hide_database_files
270
283
  end
271
284
 
272
285
  def show_duplicates
@@ -296,9 +309,7 @@ class FileDigests
296
309
 
297
310
  raise "File is not readable" unless stat.readable?
298
311
 
299
- if filename == "#{@digest_database_path}" ||
300
- filename == "#{@digest_database_path}-wal" ||
301
- filename == "#{@digest_database_path}-shm"
312
+ if @digest_database_files.include?(filename)
302
313
  puts "SKIPPING DATABASE FILE: #{filename}" if @options[:verbose]
303
314
  return
304
315
  end
@@ -460,6 +471,16 @@ class FileDigests
460
471
  time.utc.strftime("%Y-%m-%d %H:%M:%S")
461
472
  end
462
473
 
474
+ def hide_database_files
475
+ if Gem.win_platform?
476
+ @digest_database_files.each do |file|
477
+ if File.exist?(file)
478
+ system "attrib", "+H", file, exception: true
479
+ end
480
+ end
481
+ end
482
+ end
483
+
463
484
 
464
485
  # Filesystem-related helpers
465
486
 
@@ -471,7 +492,7 @@ class FileDigests
471
492
  Pathname.new(patch_path_string(path)).cleanpath
472
493
  end
473
494
 
474
- def ensure_dir_exists path
495
+ def ensure_dir_exist path
475
496
  if File.exist?(path)
476
497
  unless File.directory?(path)
477
498
  raise "#{path} is not a directory"
@@ -482,6 +503,7 @@ class FileDigests
482
503
  end
483
504
 
484
505
  def walk_files
506
+ puts "Gathering the list of files..." if @options[:verbose]
485
507
  Dir.glob(@files_path + "**" + "*", File::FNM_DOTMATCH) do |filename|
486
508
  yield filename
487
509
  end
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.28
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav Senotrusov