Sha256: 813a11efcbb62284401db6b32fa1cec00efd2a56272cd74294033dde1f71afc4

Contents?: true

Size: 566 Bytes

Versions: 15

Compression:

Stored size: 566 Bytes

Contents

module Pageflow
  class ProcessFileJob < ApplicationJob
    queue_as :resizing

    include StateMachineJob

    def perform_with_result(file, _options)
      file.attachment.reprocess!

      if file.valid?
        :ok
      else
        reset_invalid_attachment(file)
        :error
      end
    rescue ActiveRecord::RecordInvalid, Errno::ENAMETOOLONG
      reset_invalid_attachment(file)

      :error
    end

    def reset_invalid_attachment(file)
      file_name = file.file_name
      file.attachment = nil
      file.file_name = file_name
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/jobs/pageflow/process_file_job.rb
pageflow-14.5.1 app/jobs/pageflow/process_file_job.rb
pageflow-14.5.0 app/jobs/pageflow/process_file_job.rb
pageflow-14.4.0 app/jobs/pageflow/process_file_job.rb
pageflow-14.3.0 app/jobs/pageflow/process_file_job.rb
pageflow-14.2.1 app/jobs/pageflow/process_file_job.rb
pageflow-14.2.0 app/jobs/pageflow/process_file_job.rb
pageflow-14.1.1 app/jobs/pageflow/process_file_job.rb
pageflow-14.1.0 app/jobs/pageflow/process_file_job.rb
pageflow-14.0.0 app/jobs/pageflow/process_file_job.rb
pageflow-14.0.0.rc2 app/jobs/pageflow/process_file_job.rb
pageflow-14.0.0.rc1 app/jobs/pageflow/process_file_job.rb
pageflow-14.0.0.beta3 app/jobs/pageflow/process_file_job.rb
pageflow-14.0.0.beta2 app/jobs/pageflow/process_file_job.rb
pageflow-14.0.0.beta1 app/jobs/pageflow/process_file_job.rb