Class: CreateDerivativesJob
- Inherits:
-
Hyrax::ApplicationJob
- Object
- ApplicationJob
- Hyrax::ApplicationJob
- CreateDerivativesJob
- Defined in:
- app/jobs/create_derivatives_job.rb
Instance Method Summary collapse
-
#parent_needs_reindex?(file_set) ⇒ Boolean
If this file_set is the thumbnail for the parent work, then the parent also needs to be reindexed.
- #perform(file_set, file_id, filepath = nil) ⇒ Object
Instance Method Details
#parent_needs_reindex?(file_set) ⇒ Boolean
If this file_set is the thumbnail for the parent work, then the parent also needs to be reindexed.
24 25 26 27 |
# File 'app/jobs/create_derivatives_job.rb', line 24 def parent_needs_reindex?(file_set) return false unless file_set.parent file_set.parent.thumbnail_id == file_set.id end |
#perform(file_set, file_id, filepath = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/jobs/create_derivatives_job.rb', line 8 def perform(file_set, file_id, filepath = nil) return if file_set.video? && !Hyrax.config.enable_ffmpeg # Ensure a fresh copy of the repo file's latest version is being worked on, if no filepath is directly provided filepath = Hyrax::WorkingDirectory.copy_repository_resource_to_working_directory(Hydra::PCDM::File.find(file_id), file_set.id) unless filepath && File.exist?(filepath) file_set.create_derivatives(filepath) # Reload from Fedora and reindex for thumbnail and extracted text file_set.reload file_set.update_index file_set.parent.update_index if parent_needs_reindex?(file_set) end |