<commit_before>require_relative '../remote'
require_relative '../s3_bucket'
require 'digest'

module Everything
  class Blog
    module Remote
      class FileBase
        attr_reader :output_file

        def initialize(output_file)
          @output_file = output_file
        end

        def content
          raise NotImplementedError
        end

        def content_hash
          md5.hexdigest(content)
        end

        def content_type
          raise NotImplementedError
        end

        def inspect
          "#<#{self.class}: remote_key: `#{remote_key}`>"
        end

        def local_file_is_different?
          remote_file&.etag != content_hash
        end

        def send
          if remote_file_does_not_exist?
            # puts "CREATING REMOTE FILE IS DISABLED"
            # puts "CREATING REMOTE FILE"
            create_remote_file
          elsif local_file_is_different?
            # puts "UPDATING REMOTE FILE IS DISABLED"
            # puts "UPDATING REMOTE FILE"
            update_remote_file
          else
            # puts "DOING NOTHING WITH REMOTE FILE"
          end
        end

        def remote_file_does_not_exist?
          remote_file.nil?
        end

        def remote_file
          @remote_file ||= s3_bucket&.files&.head(remote_key)
            .tap{|rf| next; puts "Remote File: "; pp rf}
        end

        def remote_key
          @remote_key ||= output_file.relative_file_path
            .tap {|o| next; puts "OUTPUT RELATIVE FILE PATH: #{o}"}
        end

      private

        def create_remote_file
          s3_bucket&.files&.create(
            key: remote_key,
            body: content,<commit_msg>Add debug statements for sending remote files<commit_after>require_relative '../remote'
require_relative '../s3_bucket'
require 'digest'

module Everything
  class Blog
    module Remote
      class FileBase
        attr_reader :output_file

        def initialize(output_file)
          @output_file = output_file
        end

        def content
          raise NotImplementedError
        end

        def content_hash
          md5.hexdigest(content)
        end

        def content_type
          raise NotImplementedError
        end

        def inspect
          "#<#{self.class}: remote_key: `#{remote_key}`>"
        end

        def local_file_is_different?
          remote_file&.etag != content_hash
        end

        def send
          if remote_file_does_not_exist?
            debug_it("Creating remote file for #{inspect}")
            create_remote_file
          elsif local_file_is_different?
            debug_it("Updating remote file for #{inspect}")
            update_remote_file
          else
            debug_it("Doing nothing with remote file for #{inspect}")
          end
        end

        def remote_file_does_not_exist?
          remote_file.nil?
        end

        def remote_file
          @remote_file ||= s3_bucket&.files&.head(remote_key)
            .tap{|rf| next; puts "Remote File: "; pp rf}
        end

        def remote_key
          @remote_key ||= output_file.relative_file_path
            .tap {|o| next; puts "OUTPUT RELATIVE FILE PATH: #{o}"}
        end

      private

        def create_remote_file
          s3_bucket&.files&.create(
            key: remote_key,
            body: content,
{'fraction_non_alphanumeric': 0.06786786786786787, 'fraction_numerical': 0.0024024024024024023, 'mean_word_length': 1.728091728091728, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3002382', 'n_tokens_mistral': 965, 'n_tokens_neox': 920, 'n_words': 238}