Skip to content
Snippets Groups Projects
Commit 06f2da47 authored by Gyan Gupta's avatar Gyan Gupta Committed by Anusha Ranganathan
Browse files

Clear file on s3 on destroy fileset

parent 24561b9d
No related branches found
No related tags found
1 merge request!349Clear file on s3 on destroy fileset
...@@ -5,7 +5,7 @@ class FileSet < ActiveFedora::Base ...@@ -5,7 +5,7 @@ class FileSet < ActiveFedora::Base
self.indexer = CrcFileSetIndexer self.indexer = CrcFileSetIndexer
after_save :create_file_set_with_fast_load_meta_data after_save :create_file_set_with_fast_load_meta_data
after_destroy :destroy_set_meta_data before_destroy :destroy_set_meta_data
property :for_complex_identifier, predicate: ::RDF::Vocab::Rdms.forComplexIdentifier, multiple: false do |index| property :for_complex_identifier, predicate: ::RDF::Vocab::Rdms.forComplexIdentifier, multiple: false do |index|
index.as :stored_searchable, :facetable index.as :stored_searchable, :facetable
...@@ -79,7 +79,13 @@ class FileSet < ActiveFedora::Base ...@@ -79,7 +79,13 @@ class FileSet < ActiveFedora::Base
end end
def destroy_set_meta_data def destroy_set_meta_data
s3 = S3StorageService.new
s3.init_client
bucket_name = s3.sanitise_name(self.parent.id)
meta_data = FileSetFastLoadMetadata.find_by(fedora_file_set_id: self.id) meta_data = FileSetFastLoadMetadata.find_by(fedora_file_set_id: self.id)
meta_data.destroy! if meta_data.present? meta_data.destroy! if meta_data.present?
s3.delete_object(bucket_name, self.object_key_on_s3)
parent.update(date_modified: DateTime.now)
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment