fingerprint 1.3.2 → 1.3.3
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.
- data/bin/fingerprint +18 -8
- data/lib/fingerprint/checker.rb +8 -2
- data/lib/fingerprint/version.rb +1 -1
- metadata +3 -3
data/bin/fingerprint
CHANGED
@@ -37,6 +37,7 @@ OPTIONS = {
|
|
37
37
|
:checksums => Fingerprint::DEFAULT_CHECKSUMS,
|
38
38
|
:lockfile => true,
|
39
39
|
:additions => false,
|
40
|
+
:failures_exit_status => 0,
|
40
41
|
}
|
41
42
|
|
42
43
|
ARGV.options do |o|
|
@@ -106,6 +107,10 @@ ARGV.options do |o|
|
|
106
107
|
OPTIONS[:lockfile] = false
|
107
108
|
end
|
108
109
|
|
110
|
+
o.on("-X", "Give a non-zero exit code if errors are detected by check or verify.") do
|
111
|
+
OPTIONS[:failures_exit_status] = 1
|
112
|
+
end
|
113
|
+
|
109
114
|
o.separator ""
|
110
115
|
o.separator "Help and Copyright information:"
|
111
116
|
|
@@ -157,6 +162,16 @@ def with_lock
|
|
157
162
|
return true
|
158
163
|
end
|
159
164
|
|
165
|
+
def finish_check(error_count)
|
166
|
+
if error_count == 0
|
167
|
+
$stderr.puts "Data verified, 0 errors found."
|
168
|
+
exit(0)
|
169
|
+
else
|
170
|
+
$stderr.puts "Data inconsistent, #{error_count} errors found!"
|
171
|
+
exit(OPTIONS[:failures_exit_status])
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
160
175
|
case (OPTIONS[:mode])
|
161
176
|
when :analyze
|
162
177
|
result = with_lock do
|
@@ -214,13 +229,7 @@ case (OPTIONS[:mode])
|
|
214
229
|
|
215
230
|
error_count += Fingerprint::Checker::verify(master, copy, options)
|
216
231
|
|
217
|
-
|
218
|
-
$stderr.puts "Data verified, 0 errors found."
|
219
|
-
exit(0)
|
220
|
-
else
|
221
|
-
$stderr.puts "Data inconsistent, #{error_count} errors found!"
|
222
|
-
exit(1)
|
223
|
-
end
|
232
|
+
finish_check(error_count)
|
224
233
|
when :scan
|
225
234
|
roots = ARGV
|
226
235
|
roots << Dir.pwd if roots.size == 0
|
@@ -242,5 +251,6 @@ case (OPTIONS[:mode])
|
|
242
251
|
options = OPTIONS.dup
|
243
252
|
|
244
253
|
error_count = Fingerprint::Checker.check_files(ARGV[0], ARGV[1], options)
|
245
|
-
|
254
|
+
|
255
|
+
finish_check(error_count)
|
246
256
|
end
|
data/lib/fingerprint/checker.rb
CHANGED
@@ -59,6 +59,10 @@ module Fingerprint
|
|
59
59
|
@master.records.each_with_index do |record, processed_count|
|
60
60
|
copy_paths.delete(record.path)
|
61
61
|
|
62
|
+
if @options[:progress]
|
63
|
+
$stderr.puts "# Checking: #{record.path}"
|
64
|
+
end
|
65
|
+
|
62
66
|
next if record.mode != :file
|
63
67
|
|
64
68
|
result, message = @copy.compare(record)
|
@@ -74,7 +78,7 @@ module Fingerprint
|
|
74
78
|
end
|
75
79
|
|
76
80
|
if @options[:progress]
|
77
|
-
$stderr.puts "# Progress: File #{processed_count} / #{total_count}
|
81
|
+
$stderr.puts "# Progress: File #{processed_count} / #{total_count}; Byte #{processed_size} / #{total_size} = #{sprintf('%0.2f%', processed_size.to_f / total_size.to_f * 100.0)}"
|
78
82
|
|
79
83
|
processed_size += (record['file.size'] || 0).to_i
|
80
84
|
end
|
@@ -82,7 +86,9 @@ module Fingerprint
|
|
82
86
|
|
83
87
|
if @options[:additions]
|
84
88
|
copy_paths.each do |path, record|
|
85
|
-
|
89
|
+
next unless record.mode == :file || record.mode == :directory
|
90
|
+
|
91
|
+
yield record, :addition, "File added"
|
86
92
|
end
|
87
93
|
end
|
88
94
|
end
|
data/lib/fingerprint/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fingerprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 3
|
10
|
+
version: 1.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Samuel Williams
|