<commit_before>class UploadsController < ApplicationController
  before_action :require_logged_in

  def download
    path = Rails.root.join('public', 'uploads', params[:path])
    
    begin
      child?(Rails.root.to_s, path.to_s)
    rescue ArgumentError
      flash_message :error, "Unknown path foubd"
      return redirect_to root_path
    end
    
    @file = File.open(path).read
    
    send_file @file, type: "application/octet-stream", :x_sendfile=>true 
  end

  private
  
  def child?(root, target)
    raise ArgumentError, "target.size=#{target.size} < #{root.size} = root.size"\
      if target.size < root.size

    target[0...root.size] == root &&
      (target.size == root.size || target[root.size] == ?/)
  end

end
<commit_msg>fix type<commit_after>class UploadsController < ApplicationController
  before_action :require_logged_in

  def download
    @file = Rails.root.join('public', 'uploads', params[:path])
    
    begin
      child?(Rails.root.to_s, @file.to_s)
    rescue ArgumentError
      flash_message :error, "Unknown path foubd"
      return redirect_to root_path
    end
    
    send_file @file, type: "application/octet-stream", :x_sendfile=>true 
  end

  private
  
  def child?(root, target)
    raise ArgumentError, "target.size=#{target.size} < #{root.size} = root.size"\
      if target.size < root.size

    target[0...root.size] == root &&
      (target.size == root.size || target[root.size] == ?/)
  end

end

{'fraction_non_alphanumeric': 0.12885538039753255, 'fraction_numerical': 0.0013708019191226869, 'mean_word_length': 3.078212290502793, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3382656', 'n_tokens_mistral': 484, 'n_tokens_neox': 479, 'n_words': 103}