From 55d111ab524bb9afad87cbfbd4c1356c9b6ce621 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 18 Aug 2016 22:57:26 +0300 Subject: [PATCH] Stroy#119627029 - do not load legal doc if file is the same --- lib/tasks/legal_doc.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/legal_doc.rake b/lib/tasks/legal_doc.rake index 6820e783a..26a648ef2 100644 --- a/lib/tasks/legal_doc.rake +++ b/lib/tasks/legal_doc.rake @@ -42,7 +42,7 @@ namespace :legal_doc do LegalDocument.where(documentable_type: "Domain", documentable_id: orig_legal.documentable_id). where(checksum: orig_legal.checksum). - where.not(id: orig_legal.id).each do |new_legal| + where.not(id: orig_legal.id).where.not(path: orig_legal.path).each do |new_legal| unless modified.include?(orig_legal.id) File.delete(new_legal.path) if File.exist?(new_legal.path) new_legal.update(path: orig_legal.path) @@ -55,7 +55,7 @@ namespace :legal_doc do "object_changes->>'registrant_id'", "children->>'tech_contacts'", "children->>'admin_contacts'").flatten.uniq contact_ids = contact_ids.map{|id| id.is_a?(Hash) ? id["id"] : id}.compact.uniq LegalDocument.where(documentable_type: "Contact", documentable_id: contact_ids). - where(checksum: orig_legal.checksum).each do |new_legal| + where(checksum: orig_legal.checksum).where.not(path: orig_legal.path).each do |new_legal| unless modified.include?(orig_legal.id) File.delete(new_legal.path) if File.exist?(new_legal.path) new_legal.update(path: orig_legal.path)