<commit_before>class PhotosController < ApplicationController
  before_filter :authenticate_user!
  
  def create
    @photo = Photo.instantiate(params[:photo])
    @photo.person = current_user

    if @photo.save
      flash[:notice] = "Successfully uploaded photo."
      redirect_to @photo.album
    else
      render :action => 'album#new'
    end
  end
  
  def new
    @photo = Photo.new
  end
  
  def destroy
    @photo = Photo.where(:id => params[:id]).first
    @photo.destroy
    flash[:notice] = "Successfully deleted photo."
    redirect_to root_url
  end
  <commit_msg>RS IZ a nicer fail(notice) on wrong file format on upload<commit_after>class PhotosController < ApplicationController
  before_filter :authenticate_user!
  
  def create
    begin
      @photo = Photo.instantiate(params[:photo])
      @photo.person = current_user




      if @photo.save
        flash[:notice] = "Successfully uploaded photo."
        redirect_to @photo.album
      else
        render :action => 'album#new'
      end

    rescue
      flash[:error] = "Photo upload failed.  Are you sure that was an image?"
      redirect_to Album.first(:id => params[:photo][:album_id])
    end
  end
  
  def new
    @photo = Photo.new
  end
  
  def destroy
    @photo = Photo.where(:id => params[:id]).first
    @photo.destroy
    flash[:notice] = "Successfully deleted photo."
    redirect_to root_url
  end
  
{'fraction_non_alphanumeric': 0.09850107066381156, 'fraction_numerical': 0.0, 'mean_word_length': 2.799457994579946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3851378', 'n_tokens_mistral': 430, 'n_tokens_neox': 415, 'n_words': 113}