<commit_before>class SwObjectsController < ApplicationController
  include SwObjectHelper

  def show
    sw_object = SwObject.find_by_uri(json_params[:uri])
    sw_manifest = SwManifest.find_by_uri(json_params[:uri])

    if sw_object
      app.status 200
      case json_params[:method]
      when :head
        safe_append_header('Content-Type', sw_object.content_type)
        safe_append_header('Content-Length', sw_object.size)
        safe_append_header('X-Timestamp', sw_object.created_at.to_i)
        safe_append_header('ETag', sw_object.hash)
        safe_append_header('Date', Time.now)
      when :get
        app.send_file sw_object.file_path,
          type: sw_object.content_type,
          filename: sw_object.key.split('/').last
      end
    elsif sw_manifest
      app.status 200
      case json_params[:method]
      when :head
        safe_append_header('Content-Type', sw_manifest.content_type)
        safe_append_header('Content-Length', sw_manifest.size)
        safe_append_header('X-Timestamp', sw_manifest.created_at.to_i)
        safe_append_header('ETag', sw_manifest.hash)
        safe_append_header('Date', Time.now)
      when :get
        manifest_file(sw_manifest) do |file|
          app.send_file file,
            type: sw_manifest.content_type,
            filename: sw_manifest.key.split('/').last
        end
      end
    else
      app.status 404
    end
  end

  def update
    object_creation do |file_path|
      persist(app.request.body)
    end
  end

  def copy
    if copied_object = SwObject.find_by_uri(req_headers[:x_copy_from])
      object_creation do
        copy_file(copied_object)
      end
    elsif copied_manifest = SwManifest.find_by_uri(req_headers[:x_copy_from])
      manifest_creation do |manifest|
        manifest.sw_objects = copied_manifest.sw_objects
      end
    else<commit_msg>some corrections<commit_after>class SwObjectsController < ApplicationController
  include SwObjectHelper

  def show
    sw_object = SwObject.find_by_uri(json_params[:uri])
    sw_manifest = SwManifest.find_by_uri(json_params[:uri])

    if sw_object
      app.status 200
      case json_params[:method]
      when :head
        safe_append_header('Content-Type', sw_object.content_type)
        safe_append_header('Content-Length', sw_object.size)
        safe_append_header('X-Timestamp', sw_object.created_at.to_i)
        safe_append_header('ETag', sw_object.hash)
        safe_append_header('Date', Time.now)
      when :get
        app.send_file sw_object.file_path,
          type: sw_object.content_type,
          filename: sw_object.key.split('/').last
      end
    elsif sw_manifest
      app.status 200
      case json_params[:method]
      when :head
        safe_append_header('Content-Type', sw_manifest.content_type)
        safe_append_header('Content-Length', sw_manifest.size)
        safe_append_header('X-Timestamp', sw_manifest.created_at.to_i)
        safe_append_header('ETag', sw_manifest.hash)
        safe_append_header('Date', Time.now)
      when :get
        manifest_file(sw_manifest) do |file|
          app.send_file file,
            type: sw_manifest.content_type,
            filename: sw_manifest.key.split('/').last
        end
      end
    else
      app.status 404
    end
  end

  def update
    object_creation do
      persist(app.request.body)
    end
  end

  def copy
    if copied_object = SwObject.find_by_uri(req_headers[:x_copy_from])
      object_creation do
        copy_file(copied_object)
      end
    elsif copied_manifest = SwManifest.find_by_uri(req_headers[:x_copy_from])
      manifest_creation do |manifest|
        manifest.sw_objects = copied_manifest.sw_objects
      end
    else
{'fraction_non_alphanumeric': 0.08538232910024318, 'fraction_numerical': 0.004863550391786004, 'mean_word_length': 2.8683385579937304, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6522781', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1138, 'n_words': 201}