diff --git a/app/models/attachment.rb b/app/models/attachment.rb index ebabbf944..aa436965b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -612,14 +612,21 @@ class Attachment < ActiveRecord::Base if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || self.container_type == 'Principal') + begin self.__elasticsearch__.update_document + rescue => e + end + else + begin + self.__elasticsearch__.delete_document + rescue => e + end end end def delete_attachment_ealasticsearch_index - if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || - ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || - self.container_type == 'Principal') + begin self.__elasticsearch__.delete_document + rescue => e end end end