<commit_before>// Manage a connection to the Rackspace cloud. Retain and export handles to created resources.

var
  async = require('async'),
  pkgcloud = require('pkgcloud');

/**
 * @description Create a function that asynchronously creates a Rackspace container if it
 *   doesn't already exist.
 */
function make_container_creator(client, container_name, logical_name, cdn) {
  return function (callback) {
    var report_back = function (err, container) {
      exports[logical_name] = container;
      callback(null, container);
    };

    var cdn_enable = function (err, container) {
      container.enableCdn(container);
    };

    var handle_creation = cdn ? cdn_enable : report_back;

    // Instead of checking if the container exists first, we try to create it, and
    // if it already exists, we get a no-op (202) and move on.
    client.createContainer({ name: container_name, ttl: 31556940 }, handle_creation);
  };
}

/**
 * @description Utility function to ensure that the exported Container model includes CDN URIs when
 *   it's supposed to.
 */
function refresh(client, container_name, logical_name, callback) {
  client.getContainer(container_name, function (err, container) {
    if (err) {
      callback(err);
      return;
    }

    exports[logical_name] = container;

    callback(null);
  });
}<commit_msg>Log container creation, specify TTL correctly.<commit_after>// Manage a connection to the Rackspace cloud. Retain and export handles to created resources.

var
  async = require('async'),
  pkgcloud = require('pkgcloud'),
  config = require('./config'),
  logging = require('./logging');

var log = logging.getLogger(config.content_log_level());

/**
 * @description Create a function that asynchronously creates a Rackspace container if it
 *   doesn't already exist.
 */
function make_container_creator(client, container_name, logical_name, cdn) {
  return function (callback) {
    var report_back = function (err, container) {
      exports[logical_name] = container;

      log.debug("Container [" + container.name + "] now exists.");

      callback(null, container);
    };

    var cdn_enable = function (err, container) {
      log.debug("Enabling CDN on container [" + container.name + "].");

      client.setCdnEnabled(container, { ttl: 31536000, enabled: true }, report_back);
    };

    var handle_creation = cdn ? cdn_enable : report_back;

    log.info("Ensuring that container [" + container_name + "] exists.");

    // Instead of checking if the container exists first, we try to create it, and
    // if it already exists, we get a no-op (202) and move on.
    client.createContainer({ name: container_name }, handle_creation);
  };
}

/**
 * @description Utility function to ensure that the exported Container model includes CDN URIs when
 *   it's supposed to.
 */
function refresh(client, container_name, logical_name, callback) {
  client.getContainer(container_name, function (err, container) {
    if (err) {
      callback(err);
      return;
    }

    exports[logical_name] = container;

    callback(null);
  });
}
{'fraction_non_alphanumeric': 0.11028219266947778, 'fraction_numerical': 0.007135906584495621, 'mean_word_length': 3.6515837104072397, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1410200', 'n_tokens_mistral': 910, 'n_tokens_neox': 861, 'n_words': 285}