mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Story#119627029 - update algorithm how we merge existing legal doc files
This commit is contained in:
parent
c90c9858eb
commit
77de3ada8c
1 changed files with 8 additions and 11 deletions
|
@ -32,19 +32,16 @@ namespace :legal_doc do
|
|||
modified = Array.new
|
||||
|
||||
LegalDocument.where.not(checksum: [nil, ""]).find_each do |x|
|
||||
if File.exist?(x.path)
|
||||
next if modified.include?(x.checksum)
|
||||
next if !File.exist?(x.path)
|
||||
modified.push(x.checksum)
|
||||
|
||||
LegalDocument.where(checksum: x.checksum) do |y|
|
||||
|
||||
if x.id != y.id && !modified.include?(x.id)
|
||||
|
||||
File.delete(y.path) if File.exist?(y.path)
|
||||
y.path = x.path
|
||||
y.save
|
||||
modified.push(y.id)
|
||||
count += 1
|
||||
|
||||
end
|
||||
LegalDocument.where(checksum: x.checksum).where.not(id: x.id) do |y|
|
||||
unless modified.include?(x.id)
|
||||
File.delete(y.path) if File.exist?(y.path)
|
||||
y.update(path: x.path)
|
||||
count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue