app/jobs/characterize_job.rb in hyrax-3.6.0 vs app/jobs/characterize_job.rb in hyrax-4.0.0.beta1
- old
+ new
@@ -27,17 +27,14 @@
# @param [FileSet] file_set
# @param [String] file_id identifier for a Hydra::PCDM::File
# @param [String, NilClass] filepath the cached file within the Hyrax.config.working_path
def perform(file_set, file_id, filepath = nil)
raise "#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy?
- filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)
+ # 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)
characterize(file_set, file_id, filepath)
-
- Hyrax.publisher.publish('file.characterized',
- file_set: file_set,
- file_id: file_id,
- path_hint: filepath)
+ CreateDerivativesJob.perform_later(file_set, file_id, filepath)
end
private
def characterize(file_set, _file_id, filepath) # rubocop:disable Metrics/AbcSize
@@ -63,10 +60,10 @@
# "cold storage" archive of the parent Work. It's worth noting that adding a *new* version always touches this...
# mod time. This is done in the versioning code.
file_set.date_modified = Hyrax::TimeService.time_in_utc if file_set.characterization_proxy.original_checksum.first != previous_checksum
# set title to label if that's how it was before this characterization
- file_set.title = [file_set.characterization_proxy.original_name] if reset_title
+ file_set.title = [file_set.characterization_proxy.original_name.force_encoding("UTF-8")] if reset_title
# always set the label to the original_name
file_set.label = file_set.characterization_proxy.original_name
file_set.save!
end