fingerprint 3.3.0 → 3.4.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/fingerprint/checker.rb +4 -11
- data/lib/fingerprint/command/duplicates.rb +44 -41
- data/lib/fingerprint/command/verify.rb +1 -5
- data/lib/fingerprint/record.rb +10 -7
- data/lib/fingerprint/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe183e59d36938796040005023943811697ab7c5f4d18c78f4740dd21bdcacb5
|
4
|
+
data.tar.gz: a781c31d0eb206bf505ca521331e13681b43014a15260c7a6aeb6cf7056796c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fea4f8529180e152013a160c8e87f7deb046cd7270a2f9b4206ecb9ff84454f6fccedd93b98488cfc79baf9b33c9dcd863ce7fd586cd12da29d56203f59c31a
|
7
|
+
data.tar.gz: db95df8fbbf8b5d67a0bfe68d3953d8066c549d055c772d15705f3b54e2bf7c2f555e854335694da3ec27347e0c1d50835a3c0871b16656ca229eff70232b479
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/fingerprint/checker.rb
CHANGED
@@ -98,17 +98,10 @@ module Fingerprint
|
|
98
98
|
def self.check_files(master, copy, **options, &block)
|
99
99
|
# New API that takes two RecordSets...
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
copy_recordset = RecordSet.new
|
107
|
-
copy_recordset.parse(copy_file)
|
108
|
-
|
109
|
-
verify(master_recordset, copy_recordset, **options, &block)
|
110
|
-
end
|
111
|
-
end
|
101
|
+
master_recordset = RecordSet.load_file(master)
|
102
|
+
copy_recordset = RecordSet.load_file(copy)
|
103
|
+
|
104
|
+
verify(master_recordset, copy_recordset, **options, &block)
|
112
105
|
end
|
113
106
|
|
114
107
|
# Helper function to check two fingerprint files.
|
@@ -33,6 +33,8 @@ module Fingerprint
|
|
33
33
|
option "-i/--inverse", "Invert the output, i.e. show files which are not duplicates."
|
34
34
|
option "-x/--extended", "Include extended information about files and directories."
|
35
35
|
|
36
|
+
option "--delete", "Delete duplicates."
|
37
|
+
|
36
38
|
option "--verbose", "Verbose output, e.g. what is happening."
|
37
39
|
end
|
38
40
|
|
@@ -41,56 +43,57 @@ module Fingerprint
|
|
41
43
|
|
42
44
|
attr :duplicates_recordset
|
43
45
|
|
46
|
+
def delete(path)
|
47
|
+
FileUtils.rm_f(path)
|
48
|
+
end
|
49
|
+
|
44
50
|
def call
|
45
51
|
@duplicates_recordset = RecordSet.new
|
46
52
|
results = RecordSetPrinter.new(@duplicates_recordset, @parent.output)
|
47
53
|
|
48
54
|
master_file_path = @master
|
49
|
-
|
50
|
-
master_recordset = RecordSet.new
|
51
|
-
master_recordset.parse(master_file)
|
55
|
+
master_recordset = RecordSet.load_file(master_file_path)
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
ignore_similar = false
|
58
|
+
|
59
|
+
copy_file_paths = @copies
|
60
|
+
|
61
|
+
if copy_file_paths.size == 0
|
62
|
+
copy_file_paths = [master_file_path]
|
63
|
+
ignore_similar = true
|
64
|
+
end
|
65
|
+
|
66
|
+
copy_file_paths.each do |copy_file_path|
|
67
|
+
copy_recordset = RecordSet.load_file(copy_file_path)
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
69
|
+
copy_recordset.records.each do |record|
|
70
|
+
next unless record.file?
|
71
|
+
|
72
|
+
record.metadata['fingerprint'] = copy_file_path
|
73
|
+
|
74
|
+
# We need to see if the record exists in the master
|
75
|
+
|
76
|
+
if @options[:verbose]
|
77
|
+
$stderr.puts "Checking #{record.inspect}"
|
78
|
+
end
|
79
|
+
|
80
|
+
main_record = master_recordset.find_by_key(record)
|
81
|
+
|
82
|
+
# If we are scanning the same index, don't print out every file, just those that are duplicates within the single file.
|
83
|
+
if ignore_similar && main_record && (main_record.path == record.path)
|
84
|
+
main_record = nil
|
85
|
+
end
|
86
|
+
|
87
|
+
if main_record
|
88
|
+
record.metadata['original.path'] = main_record.path
|
89
|
+
record.metadata['original.fingerprint'] = master_file_path
|
90
|
+
results << record if !@options[:inverse]
|
66
91
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
record.metadata['fingerprint'] = copy_file_path
|
71
|
-
record.metadata['full_path'] = copy_recordset.full_path(record.path)
|
72
|
-
|
73
|
-
# We need to see if the record exists in the master
|
74
|
-
|
75
|
-
if @options[:verbose]
|
76
|
-
$stderr.puts "Checking #{record.inspect}"
|
77
|
-
end
|
78
|
-
|
79
|
-
main_record = master_recordset.find_by_key(record)
|
80
|
-
|
81
|
-
# If we are scanning the same index, don't print out every file, just those that are duplicates within the single file.
|
82
|
-
if ignore_similar && main_record && (main_record.path == record.path)
|
83
|
-
main_record = nil
|
84
|
-
end
|
85
|
-
|
86
|
-
if main_record
|
87
|
-
record.metadata['original.path'] = main_record.path
|
88
|
-
record.metadata['original.fingerprint'] = master_file_path
|
89
|
-
results << record if !@options[:inverse]
|
90
|
-
else
|
91
|
-
results << record if @options[:inverse]
|
92
|
-
end
|
92
|
+
if @options[:delete]
|
93
|
+
delete(copy_recordset.full_path(record.path))
|
93
94
|
end
|
95
|
+
else
|
96
|
+
results << record if @options[:inverse]
|
94
97
|
end
|
95
98
|
end
|
96
99
|
end
|
@@ -60,11 +60,7 @@ module Fingerprint
|
|
60
60
|
options = @options.dup
|
61
61
|
options[:output] = @parent.output
|
62
62
|
|
63
|
-
master = RecordSet.
|
64
|
-
|
65
|
-
File.open(input_file, "r") do |io|
|
66
|
-
master.parse(io)
|
67
|
-
end
|
63
|
+
master = RecordSet.load_file(input_file)
|
68
64
|
|
69
65
|
if master.configuration
|
70
66
|
options.merge!(master.configuration.options)
|
data/lib/fingerprint/record.rb
CHANGED
@@ -90,13 +90,16 @@ module Fingerprint
|
|
90
90
|
|
91
91
|
class RecordSet
|
92
92
|
def self.load_file(path)
|
93
|
+
path = File.expand_path(path)
|
94
|
+
root = File.dirname(path)
|
95
|
+
|
96
|
+
record_set = self.new(root)
|
97
|
+
|
93
98
|
File.open(path, "r") do |io|
|
94
|
-
|
99
|
+
record_set.parse(io)
|
95
100
|
end
|
96
|
-
|
97
|
-
|
98
|
-
def self.load(io)
|
99
|
-
self.new.tap{|record_set| record_set.parse(io)}
|
101
|
+
|
102
|
+
return record_set
|
100
103
|
end
|
101
104
|
|
102
105
|
def initialize(root = nil)
|
@@ -131,7 +134,7 @@ module Fingerprint
|
|
131
134
|
end
|
132
135
|
|
133
136
|
@configuration = record
|
134
|
-
@root
|
137
|
+
@root ||= @configuration.path
|
135
138
|
else
|
136
139
|
@paths[record.path] = record
|
137
140
|
|
@@ -239,7 +242,7 @@ module Fingerprint
|
|
239
242
|
elsif line.match(/^\s+([a-zA-Z\.0-9]+)\s+(.*)$/)
|
240
243
|
metadata[$1] = $2
|
241
244
|
else
|
242
|
-
|
245
|
+
raise "Unhandled line: #{line}"
|
243
246
|
end
|
244
247
|
end
|
245
248
|
|
data/lib/fingerprint/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|