<commit_before>class CmsFile < ApplicationRecord
  include CadmusFiles::File

  has_and_belongs_to_many :pages
  belongs_to :uploader, class_name: 'User', optional: true
  mount_uploader :file, CmsFileUploader

  cadmus_file :file
  validate :validate_file_name_is_unique

  def rename_file(filename)
    new_path = File.join(File.dirname(file.path), filename)

    if EnvironmentBasedUploader.use_fog?
      resource = Aws::S3::Resource.new
      bucket = resource.bucket(CmsFileUploader.fog_directory)
      object = bucket.object(file.path)
      object.move_to(bucket: bucket.name, key: new_path)<commit_msg>Set ACL on renamed files<commit_after>class CmsFile < ApplicationRecord
  include CadmusFiles::File

  has_and_belongs_to_many :pages
  belongs_to :uploader, class_name: 'User', optional: true
  mount_uploader :file, CmsFileUploader

  cadmus_file :file
  validate :validate_file_name_is_unique

  def rename_file(filename)
    new_path = File.join(File.dirname(file.path), filename)

    if EnvironmentBasedUploader.use_fog?
      resource = Aws::S3::Resource.new
      bucket = resource.bucket(CmsFileUploader.fog_directory)
      object = bucket.object(file.path)
      object.move_to({ bucket: bucket.name, key: new_path }, { acl: 'public-read' })
{'fraction_non_alphanumeric': 0.09263657957244656, 'fraction_numerical': 0.001583531274742676, 'mean_word_length': 4.851851851851852, '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': '1512180', 'n_tokens_mistral': 420, 'n_tokens_neox': 409, 'n_words': 80}