Class: Pageflow::ProcessImageOrTextTrackJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
StateMachineJob
Defined in:
app/jobs/pageflow/process_image_or_text_track_job.rb

Instance Method Summary collapse

Instance Method Details

#perform_with_result(file, _options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/pageflow/process_image_or_text_track_job.rb', line 7

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

#reset_invalid_attachment(file) ⇒ Object



22
23
24
25
26
# File 'app/jobs/pageflow/process_image_or_text_track_job.rb', line 22

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