Sha256: 69bbb465195625073770c5e9d8b51de06e6baae34eb5b7dc9ef41c4417e4299a

Contents?: true

Size: 1.06 KB

Versions: 29

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Hyrax
  module Actors
    # Responsible for removing FileSets related to the given curation concern.
    class CleanupFileSetsActor < Hyrax::Actors::AbstractActor
      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if destroy was successful
      def destroy(env)
        cleanup_file_sets(env.curation_concern)
        next_actor.destroy(env)
      end

      private

      def cleanup_file_sets(curation_concern)
        # Destroy the list source first.  This prevents each file_set from attemping to
        # remove itself individually from the work. If hundreds of files are attached,
        # this would take too long.

        # Get list of member file_sets from Solr
        fs = curation_concern.file_sets
        curation_concern.list_source.destroy
        # Remove Work from Solr after it was removed from Fedora so that the
        # in_objects lookup does not break when FileSets are destroyed.
        Hyrax::SolrService.delete(curation_concern.id)
        fs.each(&:destroy)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.4 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.3 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.2 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.1 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.0 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.0.rc3 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.0.rc2 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-5.0.0.rc1 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-3.6.0 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-4.0.0 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-4.0.0.rc3 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-4.0.0.rc2 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-4.0.0.rc1 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-3.5.0 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-4.0.0.beta2 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-3.4.2 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-4.0.0.beta1 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-3.4.1 app/actors/hyrax/actors/cleanup_file_sets_actor.rb
hyrax-3.4.0 app/actors/hyrax/actors/cleanup_file_sets_actor.rb