# frozen_string_literal: true

namespace :hyrax do
  namespace :file_sets do
    desc 'Regenerate derivatives for all FileSets in the repository'
    task regenerate_derivatives: :environment do
      FileSet.all.each do |fs|
        fs.files.each { |fi| CreateDerivativesJob.perform_later(fs, fi) }
      end
    end
  end
end

# frozen_string_literal: true

namespace :hyrax do
  namespace :file_sets do
    desc 'Regenerate derivatives for all FileSets in the repository'
    task regenerate_derivatives: :environment do
      FileSet.all.each do |fs|
        fs.files.each { |fi| CreateDerivativesJob.perform_later(fs, fi.id) }
      end
    end
  end
end

Fix SerializationError in Regenerate Derivatives job
Fix SerializationError in Regenerate Derivatives job

CreateDerivativesJob expects a FileID of type String instead of a Hydra::PCDM::File object.  
see https://github.com/samvera/hyrax/blob/main/app/jobs/create_derivatives_job.rb#L6

Running the task as-is gives me the following error:
```
 RAILS_ENV=production bundle exec rails hyrax:file_sets:regenerate_derivatives 
[DEPRECATION] PCDM is deprecating 'Class#PreservationMasterFile'. Use Class#PreservationFile instead.
rails aborted!
ActiveJob::SerializationError: Unsupported argument type: Hydra::PCDM::File
```

This was the simplest change I could make to get the task to run successfully.