50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/fingerprint/command/duplicates.rb', line 50
def call
@duplicates_recordset = RecordSet.new
results = RecordSetPrinter.new(@duplicates_recordset, @parent.output)
master_file_path = @master
master_recordset = RecordSet.load_file(master_file_path)
ignore_similar = false
copy_file_paths = @copies
if copy_file_paths.size == 0
copy_file_paths = [master_file_path]
ignore_similar = true
end
copy_file_paths.each do |copy_file_path|
copy_recordset = RecordSet.load_file(copy_file_path)
copy_recordset.records.each do |record|
next unless record.file?
record.metadata['fingerprint'] = copy_file_path
if @options[:verbose]
$stderr.puts "Checking #{record.inspect}"
end
main_record = master_recordset.find_by_key(record)
if ignore_similar && main_record && (main_record.path == record.path)
main_record = nil
end
if main_record
record.metadata['original.path'] = main_record.path
record.metadata['original.fingerprint'] = master_file_path
results << record if !@options[:inverse]
if @options[:delete]
delete(copy_recordset.full_path(record.path))
end
else
results << record if @options[:inverse]
end
end
end
end
|