Skip to content

Commit

Permalink
Removes FileSet related objects when work deleted (#6334).
Browse files Browse the repository at this point in the history
  • Loading branch information
bwatson78 committed Oct 12, 2023
1 parent 798d733 commit d92381c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/hyrax/transactions/work_destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ class WorkDestroy < Transaction
def initialize(container: Container, steps: DEFAULT_STEPS)
super
end

def call(value)
remove_file_set_related_objects(value)
super
end

private

def retrieve_file_set_objects(work_obj)
work_obj.member_ids.map { |id| Hyrax.query_service.find_by(id:) }
end

def remove_file_set_related_objects(work_obj)
file_sets = retrieve_file_set_objects(work_obj)

file_sets.each do |fs|
Steps::DeleteAllFileMetadata.new(property: :file_ids).call(fs)
Steps::DeleteAccessControl.new.call(fs)
end
end
end
end
end

0 comments on commit d92381c

Please sign in to comment.