<commit_before>class ModelImagesController < ApplicationController
  before_filter :check_model_specified
  before_filter :find_model_images, :only=>[:index]
  before_filter :find_model_image_auth,:only=>[:show,:select,:edit,:update,:destroy]

  def new
    @model_image = ModelImage.new
  end


   def create
       unless params[:model_image].blank? || params[:model_image][:image_file].blank?
         file_specified = true
         @model_image = ModelImage.new params[:model_image]
         @model_image.model_id = params[:model_id]
         @model_image.content_type = params[:model_image][:image_file].content_type
         @model_image.original_filename =  params[:model_image][:image_file].original_filename
       else
         file_specified = false
       end

       respond_to do |format|
         if file_specified && @model_image.save

           if @model_image.model.model_image_id.nil?
             @model_instance.update_attribute(:model_image_id,@model_image.id)
           end

           flash[:notice] = 'Image was successfully uploaded'
           format.html {redirect_to params[:return_to]}
         else
           @model_image = ModelImage.new
           unless file_specified
             flash.now[:error]= "You haven't specified the filename. Please choose the image file to upload."
           else
             flash.now[:error] = "The image format is unreadable. Please try again or select a different image."
           end
           format.html { render :action => 'new'}
         end
       end

   end


  def show
    params[:size] ||='200x200'
    if params[:size]=='large'
      size = ModelImage::LARGE_SIZE
    else
      size = params[:size]
    end

    @model_image.resize_image(size)

    respond_to do |format|
      format.html do
        path = @model_image.full_cache_path(size)
        send_file(path, :type => 'image/jpeg', :disposition => 'inline', :status=>304)
        headers["Content-Length"]=File.size(path).to_s
      end
      format.xml do
        @cache_file=@model_image.full_cache_path(size)
        @type='image/jpeg'
      end
    end
  end

  def index
    respond_to do |format|
      format.html
    end
  end

  def destroy<commit_msg>reverted the 304 response for model images, to see if it fixes problem on test server<commit_after>class ModelImagesController < ApplicationController
  before_filter :check_model_specified
  before_filter :find_model_images, :only=>[:index]
  before_filter :find_model_image_auth,:only=>[:show,:select,:edit,:update,:destroy]

  def new
    @model_image = ModelImage.new
  end


   def create
       unless params[:model_image].blank? || params[:model_image][:image_file].blank?
         file_specified = true
         @model_image = ModelImage.new params[:model_image]
         @model_image.model_id = params[:model_id]
         @model_image.content_type = params[:model_image][:image_file].content_type
         @model_image.original_filename =  params[:model_image][:image_file].original_filename
       else
         file_specified = false
       end

       respond_to do |format|
         if file_specified && @model_image.save

           if @model_image.model.model_image_id.nil?
             @model_instance.update_attribute(:model_image_id,@model_image.id)
           end

           flash[:notice] = 'Image was successfully uploaded'
           format.html {redirect_to params[:return_to]}
         else
           @model_image = ModelImage.new
           unless file_specified
             flash.now[:error]= "You haven't specified the filename. Please choose the image file to upload."
           else
             flash.now[:error] = "The image format is unreadable. Please try again or select a different image."
           end
           format.html { render :action => 'new'}
         end
       end

   end


  def show
    params[:size] ||='200x200'
    if params[:size]=='large'
      size = ModelImage::LARGE_SIZE
    else
      size = params[:size]
    end

    @model_image.resize_image(size)

    respond_to do |format|
      format.html do
        path = @model_image.full_cache_path(size)
        send_file(path, :type => 'image/jpeg', :disposition => 'inline')
        headers["Content-Length"]=File.size(path).to_s
      end
      format.xml do
        @cache_file=@model_image.full_cache_path(size)
        @type='image/jpeg'
      end
    end
  end

  def index
    respond_to do |format|
      format.html
    end
  end

  def destroy
{'fraction_non_alphanumeric': 0.09767545820295039, 'fraction_numerical': 0.004023245417970496, 'mean_word_length': 2.629359286293593, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2546336', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1290, 'n_words': 291}