From ed8e0ac76bddab0d74095313f36bd836d30dcb84 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Feb 2013 17:33:32 +0100 Subject: The convertion of PDFs to fax thumbnails now gets done by a delayed_job. --- app/models/fax_document.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/models/fax_document.rb') diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index 4db4980..564d3bb 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -18,8 +18,8 @@ class FaxDocument < ActiveRecord::Base has_many :fax_thumbnails, :order => :position, :dependent => :destroy - after_create :render_thumbnails after_create :convert_pdf_to_tiff + after_create :render_thumbnails # Scopes scope :inbound, where(:state => 'inbound') @@ -51,8 +51,12 @@ class FaxDocument < ActiveRecord::Base def to_s "#{self.remote_station_id}-#{self.created_at}-#{self.id}".gsub(/[^a-zA-Z0-9]/,'') end - + def render_thumbnails + self.delay.create_thumbnails_and_save_them + end + + def create_thumbnails_and_save_them tmp_dir = "/tmp/fax_convertions/#{self.id}" FileUtils.mkdir_p tmp_dir system("cd #{tmp_dir} && convert #{self.document.path} -colorspace Gray PNG:'fax_page.png'") -- cgit v1.2.3