Skip to content

Commit

Permalink
Delete spawned child works as a work is deleted
Browse files Browse the repository at this point in the history
This plugs into the cleanup file sets process, to add additional
cleanup of child works which were created as part of a IiifPrint PDF
split. Other child works are not affected.
  • Loading branch information
LaRita Robinson committed Nov 14, 2023
1 parent a23582d commit ddbeab5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/actors/iiif_print/actors/cleanup_file_sets_actor_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

# override Hyrax to remove splitting upon work delete
module IiifPrint
module Actors
# Responsible for removing FileSets related to the given curation concern.
module CleanupFileSetsActorDecorator
# @param [Hyrax::Actors::Environment] env
# @return [Boolean] true if destroy was successful
def destroy(env)
file_sets = env.curation_concern.file_sets
file_sets.each do |file_set|
# we destroy the children before the file_set, because we need the parent relationship
IiifPrint::SplitPdfs::DestroyPdfChildWorksService.conditionally_destroy_spawned_children_of(
file_set: file_set,
work: env.curation_concern
)
end
# and now back to your regularly scheduled programming
super
end
end
end
end
1 change: 1 addition & 0 deletions lib/iiif_print/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Engine < ::Rails::Engine
::BlacklightIiifSearch::IiifSearchAnnotation.prepend(IiifPrint::BlacklightIiifSearch::AnnotationDecorator)
::BlacklightIiifSearch::IiifSearch.prepend(IiifPrint::IiifSearchDecorator)
Hyrax::Actors::FileSetActor.prepend(IiifPrint::Actors::FileSetActorDecorator)
Hyrax::Actors::CleanupFileSetsActor.prepend(IiifPrint::Actors::CleanupFileSetsActorDecorator)

Hyrax.config do |config|
config.callback.set(:after_create_fileset) do |file_set, user|
Expand Down

0 comments on commit ddbeab5

Please sign in to comment.