<commit_before>module Downloader
  module FileUtils
    # Gets the id and url of a download request and generates download path for it.
    def self.generate_download_path(id, url)
      download_uri = ::URI.parse(url)
      downloaded_file_name = "#{id}_#{download_uri.path.split('/').last}"
      download_path = ENV['DOWNLOAD_PATH']
      return File.join(download_path, downloaded_file_name)
    end

    def self.write_log(id, message, options={})
      options[:mode] ||= 'a'
      File.open(File.expand_path(File.join('logs', "#{id}.txt")), options[:mode]) do |file|
        file.write(message)
      end
    end

    def self.generate_torrent(id, url)
      system("mktorrent -o #{self.generate_download_path(id, url)}.torrent \\
              -a udp://#{ENV['TRACKER_ADDRESS']}:#{ENV['TRACKER_PORT']}/announce \\
              -a tcp://#{ENV['TRACKER_ADDRESS']}:#{ENV['TRACKER_PORT']}/announce \\
              #{self.generate_download_path(id, url)}")
    end
  end
end<commit_msg>change torrent announce address from tcp to http<commit_after>module Downloader
  module FileUtils
    # Gets the id and url of a download request and generates download path for it.
    def self.generate_download_path(id, url)
      download_uri = ::URI.parse(url)
      downloaded_file_name = "#{id}_#{download_uri.path.split('/').last}"
      download_path = ENV['DOWNLOAD_PATH']
      return File.join(download_path, downloaded_file_name)
    end

    def self.write_log(id, message, options={})
      options[:mode] ||= 'a'
      File.open(File.expand_path(File.join('logs', "#{id}.txt")), options[:mode]) do |file|
        file.write(message)
      end
    end

    def self.generate_torrent(id, url)
      system("mktorrent -o #{self.generate_download_path(id, url)}.torrent \\
              -a udp://#{ENV['TRACKER_ADDRESS']}:#{ENV['TRACKER_PORT']}/announce \\
              -a http://#{ENV['TRACKER_ADDRESS']}:#{ENV['TRACKER_PORT']}/announce \\
              #{self.generate_download_path(id, url)}")
    end
  end
end
{'fraction_non_alphanumeric': 0.15262636273538158, 'fraction_numerical': 0.0, 'mean_word_length': 3.241596638655462, 'pattern_counts': {'":': 0, '<': 3, '<?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': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '491378', 'n_tokens_mistral': 653, 'n_tokens_neox': 659, 'n_words': 130}