app/models/post/file_methods.rb
# Generate the specified image type.  If options[:force_regen] is set, generate the file even
# if it already exists.
Generate the specified image type.  If options[:force_regen] is set, generate the file even
if it already exists.
Generate the specified image type . If options [ : force_regen ] is set generate the file even if it already exists .
def regenerate_images(type, options = {})
    return true unless image?
    if type == :sample
      return false unless generate_sample(options[:force_regen])
      temp_path = tempfile_sample_path
      dest_path = sample_path
    elsif type == :jpeg
      return false unless generate_jpeg(options[:force_regen])
      temp_path = tempfile_jpeg_path
      dest_path = jpeg_path
    elsif type == :preview
      return false unless generate_preview
      temp_path = tempfile_preview_path
      dest_path = preview_path
    else
      raise Exception, "unknown type: %s" % type
    end
    if File.exist?(temp_path)
      FileUtils.mkdir_p(File.dirname(dest_path), :mode => 0775)
      FileUtils.mv(temp_path, dest_path)
      FileUtils.chmod(0775, dest_path)
    end
    save
  end
def regenerate_images ( type , options = { } ) return true unless image? if type == :sample return false unless generate_sample ( options [ :force_regen ] ) temp_path = tempfile_sample_path dest_path = sample_path elsif type == :jpeg return false unless generate_jpeg ( options [ :force_regen ] ) temp_path = tempfile_jpeg_path dest_path = jpeg_path elsif type == :preview return false unless generate_preview temp_path = tempfile_preview_path dest_path = preview_path else raise Exception , "unknown type: %s" % type end if File . exist? ( temp_path ) FileUtils . mkdir_p ( File . dirname ( dest_path ) , :mode => 0775 ) FileUtils . mv ( temp_path , dest_path ) FileUtils . chmod ( 0775 , dest_path ) end save end
Generate the specified image type.
Generate the specified image type .
# Only move in the changed files on success.  When we return false, the caller won't # save us to the database; we need to only move the new files in if we're going to be # saved.  This is normally handled by move_file.
type
options