file-digests 0.0.39 → 0.0.40
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 +38 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9d040599aee9aeb62234557b2a92edec36265e4439965e4c9d00a2c9afa117a
|
4
|
+
data.tar.gz: 992fe8a843afe761537a3c48b1ecde27ccdf8101be58dd4b456572c59232141b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e15aa584690f8062a51cbb4785c9716e610258fba77859cb2b50642154701ffa1651312be1f6455921ee435ed7df5ed00bcc36f12def4009ac7edcc4aebb93e
|
7
|
+
data.tar.gz: 5c94ae4165677af0be7b790a7a92ffc9af7751f0dd2661bf238d06b02569ef4ec746908721c7d16781d11a431048759e1490f9e180ea9c2e647f5e585a3ebbe0
|
data/lib/file-digests.rb
CHANGED
@@ -139,17 +139,29 @@ class FileDigests
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def initialize_paths files_path, digest_database_path
|
142
|
+
@start_time_filename_string = Time.now.strftime("%Y-%m-%d %H-%M-%S")
|
142
143
|
@files_path = cleanup_path(files_path || ".")
|
143
144
|
raise "ERROR: Files path must be a readable directory" unless (File.directory?(@files_path) && File.readable?(@files_path))
|
144
145
|
@files_path = realpath_with_disk @files_path
|
145
146
|
|
146
|
-
@error_log_path = @files_path + "file-digests errors #{
|
147
|
+
@error_log_path = @files_path + "file-digests errors #{@start_time_filename_string}.txt"
|
148
|
+
@missing_files_path = @files_path + "file-digests missing files #{@start_time_filename_string}.txt"
|
147
149
|
|
148
150
|
@digest_database_path = digest_database_path ? cleanup_path(digest_database_path) : @files_path
|
149
151
|
@digest_database_path += ".file-digests.sqlite" if File.directory?(@digest_database_path)
|
150
152
|
ensure_dir_exist @digest_database_path.dirname
|
151
153
|
@digest_database_path = realdirpath_with_disk @digest_database_path
|
152
|
-
|
154
|
+
|
155
|
+
@digest_database_files = [
|
156
|
+
"#{@digest_database_path}",
|
157
|
+
"#{@digest_database_path}-wal",
|
158
|
+
"#{@digest_database_path}-shm"
|
159
|
+
]
|
160
|
+
|
161
|
+
@skip_files = @digest_database_files + [
|
162
|
+
@error_log_path.to_s,
|
163
|
+
@missing_files_path.to_s
|
164
|
+
]
|
153
165
|
|
154
166
|
if @options[:verbose]
|
155
167
|
puts "Target directory: #{@files_path}"
|
@@ -288,7 +300,7 @@ class FileDigests
|
|
288
300
|
if any_exceptions?
|
289
301
|
STDERR.puts "Due to previously occurred errors, missing files will not removed from the database."
|
290
302
|
else
|
291
|
-
|
303
|
+
report_missing_files
|
292
304
|
if !@options[:test_only] && (@options[:auto] || confirm("Remove missing files from the database"))
|
293
305
|
nested_transaction do
|
294
306
|
puts "Removing missing files..." if @options[:verbose]
|
@@ -356,8 +368,8 @@ class FileDigests
|
|
356
368
|
|
357
369
|
raise "File is not readable" unless stat.readable?
|
358
370
|
|
359
|
-
if @
|
360
|
-
puts "SKIPPING
|
371
|
+
if @skip_files.include?(filename)
|
372
|
+
puts "SKIPPING FILE: #{filename}" if @options[:verbose]
|
361
373
|
return
|
362
374
|
end
|
363
375
|
|
@@ -369,10 +381,6 @@ class FileDigests
|
|
369
381
|
new_digests_insert(normalized_filename, new_digest) if new_digest
|
370
382
|
process_file_indeed normalized_filename, mtime_string, digest
|
371
383
|
end
|
372
|
-
|
373
|
-
rescue => exception
|
374
|
-
@counters[:exceptions] += 1
|
375
|
-
report_file_exception exception, filename
|
376
384
|
end
|
377
385
|
|
378
386
|
def process_file_indeed filename, mtime, digest
|
@@ -428,10 +436,19 @@ class FileDigests
|
|
428
436
|
@counters[:renamed] = @db.changes
|
429
437
|
end
|
430
438
|
|
431
|
-
def
|
439
|
+
def report_missing_files
|
432
440
|
puts "\nMISSING FILES:"
|
441
|
+
write_missing_files STDOUT
|
442
|
+
if missing_files_count > 256
|
443
|
+
File.open(@missing_files_path, "a") do |f|
|
444
|
+
write_missing_files f
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
def write_missing_files dest
|
433
450
|
missing_files_select_all_filenames.each do |record|
|
434
|
-
puts record["filename"]
|
451
|
+
dest.puts record["filename"]
|
435
452
|
end
|
436
453
|
end
|
437
454
|
|
@@ -583,21 +600,21 @@ class FileDigests
|
|
583
600
|
def walk_files(path, &block)
|
584
601
|
Dir.each_child(path, encoding: "UTF-8") do |item|
|
585
602
|
item = "#{path}#{File::SEPARATOR}#{item}"
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
if File.
|
603
|
+
begin
|
604
|
+
item_perhaps_nt_path = perhaps_nt_path item
|
605
|
+
|
606
|
+
unless File.symlink? item_perhaps_nt_path
|
607
|
+
if File.directory?(item_perhaps_nt_path)
|
608
|
+
raise "Directory is not readable" unless File.readable?(item_perhaps_nt_path)
|
591
609
|
walk_files(item, &block)
|
592
610
|
else
|
593
|
-
|
594
|
-
@counters[:exceptions] += 1
|
611
|
+
yield item
|
595
612
|
end
|
596
|
-
else
|
597
|
-
yield item
|
598
613
|
end
|
614
|
+
rescue => exception
|
615
|
+
@counters[:exceptions] += 1
|
616
|
+
report_file_exception exception, item
|
599
617
|
end
|
600
|
-
|
601
618
|
end
|
602
619
|
end
|
603
620
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-digests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav Senotrusov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openssl
|